338
211

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Python】処理にかかる時間を計測して表示

Last updated at Posted at 2014-10-20

#はじめに
以前書いた『【PHP】処理にかかる時間を計測して時間・分・秒で表示』という記事がまぁまぁ反響があったので今回はPythonで。

#サンプルコード

hoge.py
#-*- using:utf-8 -*-
import time

if __name__ == '__main__':
	start = time.time()
	for i in range(0,11):
		print "a"
	elapsed_time = time.time() - start
	print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")

まぁ、やっていることはほとんどPHPのときと同じです。
基本的に
(処理時間)=(処理が終わった時間)ー(処理を始めた時間)
というアルゴリズムは変わらないので(^^;)

338
211
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
338
211

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?