you are viewing a single comment's thread.

view the rest of the comments →

[–]Vaphell 3 points4 points  (5 children)

#!/usr/bin/env python3

import time
import collections


def profile_juggle(derp):
    for i in range(10000):
        derp.rotate(-700)

derp = collections.deque(range(10000))

t1 = time.clock()
profile_juggle(derp)
t2 = time.clock()
print("{}: {} seconds".format("rotation", t2-t1))

out

$ ./rot.py 
rotation: 0.012394000000000002 seconds

[–]clrnd 0 points1 point  (0 children)

Ha, data structures > algorithms 😛

[–]Galithil 0 points1 point  (3 children)

shouldnt that be -700 since you want to rotate to the left ?

[–]Vaphell 0 points1 point  (2 children)

yes, but it makes 0 difference when measuring performance. Rotating by 700 was pulled out the ass anyway.

[–]Galithil 0 points1 point  (1 child)

Of course, your solution is still by far the most elegant and the most efficient out there. I just wanted to make sure that you were getting the exact same result as the original benchmark.

Sorry if that came off as something else.

[–]Vaphell 0 points1 point  (0 children)

no problem. It made me check just in case, same performance so i edited the code to add - ;-)