[Python] Measures and displays the time required for processing

Introduction

The article I wrote earlier, "[PHP] Measure the time required for processing and display it in hours, minutes, and seconds" has received a good response. This time in Python.

Sample code

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]")

Well, what I'm doing is almost the same as in PHP. fundamentally (Processing time) = (Time when processing ended)-(Time when processing started) Because the algorithm does not change (^^;)

Recommended Posts

[Python] Measures and displays the time required for processing
See python for the first time
Check the processing time and the number of calls for each process in python (cProfile)
Python Master RTA for the time being
A function that measures the processing time of a method in python
MongoDB for the first time in Python
Tips for Python beginners to use the Scikit-image example for themselves 8 Processing time measurement and profiler
Use logger with Python for the time being
I tried python programming for the first time.
Image processing? The story of starting Python for
What I got into Python for the first time
I tried Python on Mac for the first time.
I tried python on heroku for the first time
Until you can install blender and run it with python for the time being
Kaggle for the first time (kaggle ①)
python3 Measure the processing speed.
Kaguru for the first time
[Python] Iterative processing (for, while)
Set the environment variables required for PySide (Qt4) and PyQt (Qt5)
[Python] Create a date and time list for a specified period
[Understand in the shortest time] Python basics for data analysis
[Python] Display the elapsed time in hours, minutes, and seconds (00:00:00)
Get the current date and time in Python, considering the time difference
[Python] Strengths and weaknesses of DataFrame in terms of time required
Leave the troublesome processing to Python
The story of Python and the story of NaN
Python parallel processing (multiprocessing and Joblib)
Differences C # engineers felt when learning python for the first time
Understanding the python class Struggle (1) Let's move it for the time being
Personal notes for python image processing
I tried to create serverless batch processing for the first time with DynamoDB and Step Functions
[For self-learning] Go2 for the first time
Dockerfile with the necessary libraries for natural language processing in python
Let's touch Google's Vision API from Python for the time being
Create a CGH for branching a laser in Python (laser and SLM required)
What is the python underscore (_) for?
python string processing map and lambda
Start Django for the first time
The story of returning to the front line for the first time in 5 years and refactoring Python Django
python memo: enumerate () -get index and element of list at the same time and turn for statement
python> Processing time measurement> time.time () --start_time
Try using FireBase Cloud Firestore in Python for the time being
Command for the current directory Python
I want to separate the processing between test time and production environment
[Python] [Machine learning] Beginners without any knowledge try machine learning for the time being
How to get the date and time difference in seconds with python
python> array> Determine the number and initialize> mylist = [idx for idx in range (10)] / mylist = [0 for idx in range (10)] >> mylist = [0] * 10
[Python] Case where the execution time differs between the built-in list and deque
Python beginner ~ Round off the Nth decimal place and output ~ (for memo)
Get and convert the current time in the system local timezone with python
Impressions and memorandums when working with VS code for the first time
Stream processing for Python and SensorTag, Kafka, Spark Streaming --Part 1: Raspberry Pi 3
Technique to stop drawing the screen and reduce the waiting time for baking
A useful note when using Python for the first time in a while
I measured the speed of list comprehension, for and while with python2.7.
Python: I want to measure the processing time of a function neatly
Since I'm free, the front-end engineer tried Python (v3.7.5) for the first time.
Socket communication and multi-thread processing by Python
[Python] Matrix multiplication processing time using NumPy
I tried tensorflow for the first time
6 Python libraries for faster development and debugging