MCPcopy Create free account
hub / github.com/ActiveState/code / gprofile

Function gprofile

recipes/Python/578615_graph/recipe-578615.py:608–629  ·  view source on GitHub ↗
(g, size=100)

Source from the content-addressed store, hash-verified

606
607
608def gprofile(g, size=100):
609 import time
610 print "Profiling (ignoring debug)..."
611 _DEBUG = 0
612 for i in [1,2]:
613 start=time.clock()
614 g.add(range(size),range(100,size + 100))
615 finish=time.clock()
616 print "Add %i, 100-(%i+100); pass %i: %5.2fs" % (size, size, i, (finish-start))
617 for i in [1,2]:
618 start=time.clock()
619 g.discard(range(size + 50), range(100))#, range(1000))
620 finish=time.clock()
621 print "Discard (%i+50), 100; pass %i: %5.2fs" % (size, i, (finish-start))
622 g.clear()
623 g.add(0)
624 for i in [1,2]:
625 start=time.clock()
626 g[0].update(range(size))
627 finish=time.clock()
628 print "Update %i, %i; pass %i: %5.2fs" % (size, size, i, (finish-start))
629 g.clear()
630
631def _test():
632 """Miscellaneous tests.

Callers

nothing calls this directly

Calls 5

rangeFunction · 0.85
addMethod · 0.45
discardMethod · 0.45
clearMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected