PHP Benchmark Tool
composer update
php phpbench run
Create a new class and save it into the Benchmarks
folder. Add two methods each having using`` as prefix for the method's name. Place your code, which you want to bench mark into they methods. Run
phpbench run```.
Question: Is type casting variables faster than using the corresponding function? Answer: Yes, by ~50%.
<?php
namespace Bench\Benchmarks;
class intvalVSintCasting
{
public function usingIntval()
{
intval(2.3);
}
public function usingIntCasting()
{
(int) 2.3;
}
}