Is there any simple way to benchmark python script?

前端 未结 10 784
借酒劲吻你
借酒劲吻你 2020-11-28 00:53

Usually I use shell command time. My purpose is to test if data is small, medium, large or very large set, how much time and memory usage will be.

Any t

10条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 01:16

    The easy way to quickly test any function is to use this syntax : %timeit my_code

    For instance :

    %timeit a = 1
    
    13.4 ns ± 0.781 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)
    

提交回复
热议问题