Skip to main content
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

I am posting sample test runs for my usage of timeit module for timing for the following code. I wrote it for this questionthis question.

I am posting sample test runs for my usage of timeit module for timing for the following code. I wrote it for this question.

I am posting sample test runs for my usage of timeit module for timing for the following code. I wrote it for this question.

added 18 characters in body; edited tags; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

Is this the proper way of doing timing Timing analysis of many test cases in Python or not

Chat room I am learning about timing analysis in Python. I used time module before it was pointed out that timeit module would be better for discussing this questiontiming analysis.


I am learning about timing analysis in Python. I used `time` module before it was pointed out that `timeit` module would be better for timing analysis.
>>> ================================ RESTART ================================
>>> 
0.0643831414457
0.0445699517515
0.0446611241927
0.0616633662243
>>> ================================ RESTART ================================
>>> 
0.0625827896417
0.045101588386
0.0443568108447
0.0607123363607
>>> ================================ RESTART ================================
>>> 
0.0647336488305
0.0596154305912
0.0445711673841
0.0614101094434
>>> ================================ RESTART ================================
>>> 
0.0689924148581
0.0502542495475
0.0443466805735
0.0903267660811
>>> ================================ RESTART ================================
>>> 
0.0695374234506
0.0579001730656
0.0443790974415
0.0835670386907
>>> ================================ RESTART ================================
>>> 
0.0675612101379
0.05079925814
0.044170413854
0.0681050030978
>>> ================================ RESTART ================================
>>> 
0.0643831414457
0.0445699517515
0.0446611241927
0.0616633662243
>>> ================================ RESTART ================================
>>> 
0.0625827896417
0.045101588386
0.0443568108447
0.0607123363607
>>> ================================ RESTART ================================
>>> 
0.0647336488305
0.0596154305912
0.0445711673841
0.0614101094434
>>> ================================ RESTART ================================
>>> 
0.0689924148581
0.0502542495475
0.0443466805735
0.0903267660811
>>> ================================ RESTART ================================
>>> 
0.0695374234506
0.0579001730656
0.0443790974415
0.0835670386907
>>> ================================ RESTART ================================
>>> 
0.0675612101379
0.05079925814
0.044170413854
0.0681050030978

Is this the proper way of doing timing analysis of many test cases in Python or not

Chat room for discussing this question.


I am learning about timing analysis in Python. I used `time` module before it was pointed out that `timeit` module would be better for timing analysis.
>>> ================================ RESTART ================================
>>> 
0.0643831414457
0.0445699517515
0.0446611241927
0.0616633662243
>>> ================================ RESTART ================================
>>> 
0.0625827896417
0.045101588386
0.0443568108447
0.0607123363607
>>> ================================ RESTART ================================
>>> 
0.0647336488305
0.0596154305912
0.0445711673841
0.0614101094434
>>> ================================ RESTART ================================
>>> 
0.0689924148581
0.0502542495475
0.0443466805735
0.0903267660811
>>> ================================ RESTART ================================
>>> 
0.0695374234506
0.0579001730656
0.0443790974415
0.0835670386907
>>> ================================ RESTART ================================
>>> 
0.0675612101379
0.05079925814
0.044170413854
0.0681050030978

Timing analysis of many test cases in Python

I am learning about timing analysis in Python. I used time module before it was pointed out that timeit module would be better for timing analysis.

>>> ================================ RESTART ================================
>>> 
0.0643831414457
0.0445699517515
0.0446611241927
0.0616633662243
>>> ================================ RESTART ================================
>>> 
0.0625827896417
0.045101588386
0.0443568108447
0.0607123363607
>>> ================================ RESTART ================================
>>> 
0.0647336488305
0.0596154305912
0.0445711673841
0.0614101094434
>>> ================================ RESTART ================================
>>> 
0.0689924148581
0.0502542495475
0.0443466805735
0.0903267660811
>>> ================================ RESTART ================================
>>> 
0.0695374234506
0.0579001730656
0.0443790974415
0.0835670386907
>>> ================================ RESTART ================================
>>> 
0.0675612101379
0.05079925814
0.044170413854
0.0681050030978
Notice removed Canonical answer required by Aseem Bansal
Bounty Ended with ruds's answer chosen by Aseem Bansal
added 273 characters in body
Source Link
Aseem Bansal
  • 2.3k
  • 3
  • 22
  • 37

**Please note that** I started using Python 3 while I was still discussing the question. I won't be using anything specific to Python 3 so all codes can be run on Python 2. Anyone wanting to run new codes will just need to change the `print` statements. Nothing else.

**Please note that** I started using Python 3 while I was still discussing the question. I won't be using anything specific to Python 3 so all codes can be run on Python 2. Anyone wanting to run new codes will just need to change the `print` statements. Nothing else.
Updated with a testing function
Source Link
Aseem Bansal
  • 2.3k
  • 3
  • 22
  • 37
Loading
added 139 characters in body
Source Link
Aseem Bansal
  • 2.3k
  • 3
  • 22
  • 37
Loading
added 3240 characters in body
Source Link
Aseem Bansal
  • 2.3k
  • 3
  • 22
  • 37
Loading
Tweeted twitter.com/#!/StackCodeReview/status/357459955571372032
Notice added Canonical answer required by Aseem Bansal
Bounty Started worth 50 reputation by Aseem Bansal
edited title
Link
Aseem Bansal
  • 2.3k
  • 3
  • 22
  • 37
Loading
edited title
Link
Aseem Bansal
  • 2.3k
  • 3
  • 22
  • 37
Loading
Source Link
Aseem Bansal
  • 2.3k
  • 3
  • 22
  • 37
Loading