0

How to measure the time of this code with timeit?(all functions have been defined)

    for i in range (1,10):
        bh = BinHeap()
        facc=[random.randrange(1,101,1) for _ in range (10+i)]
        bh.buildHeap(facc)
        print(bh.heapList)
        i=i+1
christ
  • 11
  • 1
  • 3
  • possible duplicate of [How to use timeit when timing a function](http://stackoverflow.com/questions/19010793/how-to-use-timeit-when-timing-a-function) –  Feb 12 '15 at 06:47
  • (you'll have to put that code in a function before) –  Feb 12 '15 at 06:47
  • Preface: this is not an answer to anything ... What do you expect the `i=i+1` to do on the last line -- Because if you think it is doing _something_, it probably isn't unless there's more code to follow that you're not showing... – mgilson Feb 12 '15 at 06:48

1 Answers1

0

Try the documentation on Profiling

python -m cProfile [-o output_file] [-s sort_order] myscript.py

and

cProfile.run('BinHeap()')
John Mee
  • 50,179
  • 34
  • 152
  • 186