Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do You Rapidly Benchmark Scripts

I've seen a lot of blogs where authors discuss throwing together quick benchmark tests, like this Ruby 1.9.0 v Python 2.5.1 that Antonio Cangiano "throws together at 3am."

Is there a simple way to time a script to the millisecond like that that I'm unaware of? Is he probably using built-in functions of OS X or individual libraries? Does Python have a standard lib for this?

How would you do this if you were just going to take the path of least resistance and throw it together at 3am?

like image 729
urbushey Avatar asked Feb 23 '26 14:02

urbushey


1 Answers

Take a look at the timeit module.

like image 193
Rob Wouters Avatar answered Feb 26 '26 04:02

Rob Wouters