15

I have written 2 functions doing the exact same thing, but I don't know which one is faster and better. How do I compare these 2 functions to see which one is better in terms of performance and everything?

alwbtc
  • 28,057
  • 62
  • 134
  • 188

2 Answers2

12

The timeit module will do ya.

kindall
  • 178,883
  • 35
  • 278
  • 309
4

Once you've found out which function is faster using the timeit module, you can also get more precise details of where the differences are by using the profile module.

ekhumoro
  • 115,249
  • 20
  • 229
  • 336