Skip to content

Instantly share code, notes, and snippets.

@weltling
Created July 27, 2015 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weltling/cd7f8127378989cca87c to your computer and use it in GitHub Desktop.
Save weltling/cd7f8127378989cca87c to your computer and use it in GitHub Desktop.
<?php
ini_set('pcre.jit', 0);
$t0 = microtime(true);
for ($i = 0; $i < 4000; $i++) {
preg_match(",$i,", "$i");
}
echo "achieved in " . (microtime(true) - $t0);
ini_set('pcre.jit', 1);
$r = preg_match('/^(A{1,2}B)+$/', str_repeat('AB',8192));
if (false === $r) {
var_dump($r, "last error: " . preg_last_error());
ini_set('pcre.jit', 0);
$r = preg_match('/^(A{1,2}B)+$/', str_repeat('AB',8192));
echo 'was false' . PHP_EOL;
}
var_dump($r, "last error: " . preg_last_error());
ini_set('pcre.jit', 0);
$t0 = microtime(true);
for ($i = 0; $i < 4000; $i++) {
preg_match(",$i,", "$i");
}
echo "achieved in " . (microtime(true) - $t0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment