Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 测量字节码使用率_Python_Compiler Construction_Interpreter_Bytecode - Fatal编程技术网

Python 测量字节码使用率

Python 测量字节码使用率,python,compiler-construction,interpreter,bytecode,Python,Compiler Construction,Interpreter,Bytecode,我正在寻找一种绝对方法来对python中执行的计算进行基准测试/度量。在Java中,可以计算给定指令集的字节码使用情况。在Python中有类似的方法吗 只要差异最小(例如,时间对运行代码的机器过于敏感),我愿意接受其他建议来衡量计算的执行情况。查看 看看这本书 >>> import dis >>> def x(a,b): ... return a+b ... >>> dis.dis(x) 2 0 LOAD_F

我正在寻找一种绝对方法来对python中执行的计算进行基准测试/度量。在Java中,可以计算给定指令集的字节码使用情况。在Python中有类似的方法吗

只要差异最小(例如,时间对运行代码的机器过于敏感),我愿意接受其他建议来衡量计算的执行情况。

查看

看看这本书

>>> import dis
>>> def x(a,b):
...     return a+b
... 
>>> dis.dis(x)
  2           0 LOAD_FAST                0 (a)
              3 LOAD_FAST                1 (b)
              6 BINARY_ADD          
              7 RETURN_VALUE