0

Checking performance of programs

What is a good way of checking the performance (running time, running space, etc) of programs? Whenever I use the timeit module for timing and comparing the runtime of two codes, there always seems to be a trend where the first code that is timed is slower than the rest or something like that. I’m not sure if I’m using it correctly. Here is an example. https://code.sololearn.com/czdIuUwupePb/?ref=app

18th Jan 2020, 7:51 PM
Zerokles
Zerokles - avatar
2 Answers
+ 3
How about using the actual time module timeA = time.now() // some code timeB = time.now() print((timeA - timeB)) # converting them to seconds
18th Jan 2020, 11:48 PM
Mirielle
Mirielle - avatar
+ 2
When I ran your code a few times, I got very mixed results, the first test 'won' plenty.
18th Jan 2020, 7:54 PM
HonFu
HonFu - avatar