Last active
October 29, 2017 14:37
-
-
Save dmsnell/0849dec331d000e25e649fa351ba2db6 to your computer and use it in GitHub Desktop.
Run the parser from Gutenberg over test documents to measure its speed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Set the $RUNS and run `php -f benchmark-gutenberg-php-parser.php` | |
*/ | |
// I ran this file from the `Gutenberg/lib` directory | |
require_once( 'parser.php' ); | |
$RUNS = 2000; | |
$content = file_get_contents( 'https://pastebin.com/raw/R8Zue5kQ' ); | |
$parser = new Gutenberg_PEG_Parser; | |
$tic = microtime( true ); | |
for ( $i = 0; $i < $RUNS; $i++ ) { | |
$parser->parse( $content ); | |
} | |
$toc = microtime( true ); | |
$delta = $toc - $tic; | |
echo "Took {$delta}s" . PHP_EOL; | |
$avg = $delta * 1000 / $RUNS; | |
echo "Took average {$avg}ms" . PHP_EOL; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment