当前位置: 动力学知识库 > 问答 > 编程问答 >

python - Recommended tools for benchmarking Ruby and Perl

问题描述:

I want to compare the execution time for mathematical equations for different dynamic, interpreted programming languages like Ruby, Perl, and Python.

In Python, there is the convenient timeit module, which allows me to time, where I can simply time for, e.g., a least squares fit (python_lstsqr(x,y)) via

min(timeit.Timer('python_lstsqr(x, y)',

'from __main__ import python_lstsqr, x, y')\

.repeat(repeat=3, number=1000))

(here the best of 3 repetitions and 1000 loops per repetition)

Are there equivalents in Perl and Ruby?

网友答案:

Good old time ?

For Perl, you can use built-in Benchmark or Time::Stopwatch.

For Ruby, the built-in benchmark is good enough.

分享给朋友:
您可能感兴趣的文章:
随机阅读: