Python 処理速度の計測

import time;

def mtime(start,end):
   process = end - start;
   h = int(process / 3600);
   process -= h * 3600;
   m = int(process / 60);
   process -= m * 60;
   s = process;
   print "time: %dh %dm %fs" % (h, m, s);

def foo():
   start = time.time();

   for i in range(0,10000000):
       pass

   end = time.time();
   mtime(start,end)

foo()   

この記事が気に入ったらサポートをしてみませんか?