Is it possible?
Say I have some code in PHP:
... some PHP code here
Is there a way such that:
start_point();
... some PHP code here
end_point();
$v = dump_number_of_CPU_instructions();
echo $v;
I am expecting $v to be an integer that gives the number of CPU instructions that the code between start_point() and end_point() compiles into.
PHP is not compiled into machine code, but rather "bytecode", which are then interpreted by the PHP engine. I don't think its practical to try to find the number of CPU instructions.
There are a number of tools floating around to get the bytecode (see John Bafford's response to this for one).
The processing of the bytecode uses optimizations and caches, and does, of course, depend on the processor type, so I doubt it's practical to associate a CPU cycle count (or even time) associated with a particular bytecode.
Dealing with bytecode is not for the faint of heart. Most people just try to time the PHP code and settle for that.