我想计算各种语言的代码的执行时间,如java,python,javascript。如何获得这些代码的执行时间。是否有任何工具可用于python包或任何其他工具来通过传递文件(任何文件java或python)路径来计算执行时间。请分享您的建议。如何获取代码的执行时间?
我知道通过在Python代码中使用时间模块获取执行时间。如何在python中执行Javascript和java代码并获得通用函数的执行时间。
我试过下面的方法。
import time
def get_exectime(file_path): # pass path of any file python,java,javascript, html, shell
start_time=time.time()
# execute the file given here. How to execute all file types here?
end_time=time.time()
exec_time=end_time-start_time
print(exec_time)
有没有其他方法可以实现这个目标?