I am trying to use the timeit module for python and it appears as if there's an error in the timeit source code (though this doesn't seem right).
Here's the snippet of the code being run:
def recordCuckoo(amtElements, loadFactor):
'''
Determines the average lookup speed in seconds of a cuckoo hash table
with @amtElements elements and a load factor of @loadFactor
'''
mySetup = '''
import Statistics
import random
import hashingLibrary
from CuckooHashing import *
'''
controlStatement = "Statistics.timeCuckooControl(" + str(amtElements) + "," + str(loadFactor) + ")"
testStatement = "Statistics.timeCuckoo(" + str(amtElements) + "," + str(loadFactor) + ")"
controlTime = timeit.timeit(controlStatement, setup=mySetup, number=1)
testTime = timeit.timeit(testStatement, setup=mySetup, number=1)
lookupTime = (testTime - controlTime)/1000000
print ("The average lookup time for a cuckoo table with {0} elements and a load factor of {1} was:".format(amtElements, loadFactor))
print (lookupTime)
return lookupTime
if __name__ == "__main__":
recordCuckoo(100, 0.5)
And I receive the following error when I run it:
Traceback (most recent call last):
File "C:\Python34\CuckooHashing\Statistics.py", line 308, in <module>
recordCuckoo(100, 0.5)
File "C:\Python34\CuckooHashing\Statistics.py", line 267, in recordCuckoo
controlTime = timeit.timeit(controlStatement, setup=mySetup, number=1)
File "C:\Python34\lib\timeit.py", line 213, in timeit
return Timer(stmt, setup, timer).timeit(number)
File "C:\Python34\lib\timeit.py", line 122, in __init__
code = compile(src, dummy_src_name, "exec")
File "<timeit-src>", line 9
_t0 = _timer()
^
IndentationError: unindent does not match any outer indentation level
I understand that the error is most likely between the keyboard and chair, but the error I'm receiving appears to indicate that there's an improper space/tab in the timeit module. What is going on???