Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

はじめに

以前書いた『【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のときと同じです。
基本的に
(処理時間)=(処理が終わった時間)ー(処理を始めた時間)
というアルゴリズムは変わらないので(^^;)

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした