Last active
December 31, 2015 21:19
-
-
Save smerritt/8045982 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
import benchmark | |
import heapq | |
class BenchHeapq(benchmark.Benchmark): | |
def eachSetUp(self): | |
self.size = 500 | |
self.big = range(500 * self.size) | |
self.small = range(2 * self.size) | |
heapq.heapify(self.big) | |
heapq.heapify(self.small) | |
def test_big_heappop(self): | |
for _ in xrange(self.size): | |
heapq.heappop(self.big) | |
def test_small_heappop(self): | |
for _ in xrange(self.size): | |
heapq.heappop(self.small) | |
def test_bigpop(self): | |
for _ in xrange(self.size): | |
self.big.pop() | |
def test_smallpop(self): | |
for _ in xrange(self.size): | |
self.small.pop() | |
if __name__ == '__main__': | |
benchmark.main(each=50, numberFormat="%.4g") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment