title: Why does the C# RegexOptions.Compiled makes the match slower?
body: <p>I have the following code:</p>
  
  <pre><code>static void Main(string[] args)
  {
      const string RegXPattern = @"/api/(?&lt;controller&gt;\w+)/(?&lt;action&gt;\w+)/?$";
      var regex = new Regex(RegXPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
  
      const string InputToMatch = "/api/person/load";
  
      regex.IsMatch(InputToMatch); // Warmup
  
      var sw = Stopwatch.StartNew();
      for (int i = 0; i &lt; 10000000; i++)
      {
          var match = regex.IsMatch(InputToMatch);
      }
      sw.Stop();
  
      Console.WriteLine(sw.Elapsed.ToString());
      Console.ReadLine();
  }
  </code></pre>
  
  <p>Running the above on my machine under <em>Releae</em>, finishes in around <strong>18</strong> seconds and removing the <code>RegexOptions.Compiled</code> makes it run in <strong>13</strong> seconds.</p>
  
  <p>My understanding was that including this flag would make the match faster but in my example it is resulting in <em>~30%</em> lower performance.</p>
  
  <p>What am I missing here?</p>