Created
December 6, 2014 14:45
-
-
Save andreyfedoseev/25099bf6474e2d45f0ed to your computer and use it in GitHub Desktop.
Test the complexity of Python bisect module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
S = """ | |
bisect.bisect_left(range({N}), {x}) | |
""" | |
if __name__ == '__main__': | |
import timeit | |
from matplotlib import pyplot | |
Ns = [] | |
Ts = [] | |
for log_N in range(3, 20): | |
N = 2 ** log_N | |
Ns.append(N) | |
Ts.append(timeit.timeit(S.format(N=N, x=0), setup="import bisect", number=100)) | |
pyplot.plot(Ns, Ts) | |
pyplot.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment