Skip to content

Instantly share code, notes, and snippets.

@lipemat
Created July 9, 2023 06:50
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 lipemat/9b9ab5ed40df86da3915b572ff3141ae to your computer and use it in GitHub Desktop.
Save lipemat/9b9ab5ed40df86da3915b572ff3141ae to your computer and use it in GitHub Desktop.
Example PHPBench PHP 8.1 errors
<?php
/**
* @notice This file must live in a "benchmarks" directory for this exmaple.
*/
class Filemtime_VS_MD5_VS_Hash_File_Bench {
/**
* @Revs(1000)
* @Iterations(3)
*/
public function bench_filetime() : void {
filemtime( __FILE__ );
}
/**
* @Revs(1000)
* @Iterations(3)
*/
public function bench_md4_file() : void {
hash_file( 'md4', __FILE__ );
}
/**
* @Revs(1000)
* @Iterations(3)
*/
public function bench_md5_file() : void {
md5_file( __FILE__ );
}
/**
* @Revs(1000)
* @Iterations(3)
*/
public function bench_fnv1a_file() : void {
hash_file( 'fnv1a64', __FILE__ );
}
/**
* @Revs(1000)
* @Iterations(3)
*/
public function bench_murmur_file() : void {
hash_file( 'murmur3f', __FILE__ );
}
}
{
"runner.php_disable_ini": true,
"runner.path": "benchmarks"
}
php phpbench.phar run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment