M
Markus
You know you're guilty of early/over optimisation, when it's almost two
in the morning and the file open in front of you reads as follows.
The code you are about to read is real...
Some of the variable names have been changed
to protect the families of those involved.
[-snip-]
from timeit import Timer
if __name__=='__main__':
t = Timer('len(argv)==1','from sys import argv')
print "%f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
t = Timer('argv[0]==argv[-1]','from sys import argv')
print "%f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
[-snip-]
For anyone is in danger of making the same mistakes I've made...
the results were:
0.219154 usec/pass
0.297468 usec/pass
If anyone doesn't understand...
Timer is a "Class for timing execution speed of small code snippets."
The quoted description of Timer and the original code I derived the
above snippet from, can be found in the Python documentation.
Finally, for anyone who is wondering...
I will seek help as soon as I have some free time.
Markus
in the morning and the file open in front of you reads as follows.
The code you are about to read is real...
Some of the variable names have been changed
to protect the families of those involved.
[-snip-]
from timeit import Timer
if __name__=='__main__':
t = Timer('len(argv)==1','from sys import argv')
print "%f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
t = Timer('argv[0]==argv[-1]','from sys import argv')
print "%f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
[-snip-]
For anyone is in danger of making the same mistakes I've made...
the results were:
0.219154 usec/pass
0.297468 usec/pass
If anyone doesn't understand...
Timer is a "Class for timing execution speed of small code snippets."
The quoted description of Timer and the original code I derived the
above snippet from, can be found in the Python documentation.
Finally, for anyone who is wondering...
I will seek help as soon as I have some free time.
Markus