dongsonghen9931 2018-09-05 04:22
浏览 4

从脚本中的A点到B点获取CPU指令数

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.

  • 写回答

1条回答 默认 最新

  • douquqiang1513 2018-09-05 04:47
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程