How to Time Functions in Python using time.time

Publié le: 31 août 2018
sur la chaîne: Python Marathon
2,280
29

Descargar el Código: patreon.com/pythonmaraton

Join Patreon: patreon.com/pythonmaraton
^Downloadable code & more! This video teaches you how to time functions in python. Import time and then you can time how many seconds it takes for something to happen. This has endless applications.

This is a Python anaconda tutorial for help with coding, programming, or computer science. These are short python videos dedicated to troubleshooting python problems and learning Python syntax. For more videos see Python Help playlist by Rylan Fowers.

✅Subscribe:    / @pythonmaraton  

📺Channel:    / @pythonmaraton  

▶️Watch Latest Python Content:    • Python String Slice and List Slice  

▶️Watch Latest Other Content:    • Video  





TIME FUNCTIONS PYTHON

I will show you how to time functions in python. We are in a text editor and first let me import time

and we will do an if name equal main

First I am going to save a start time as a variable named start.

Now lets write a small function we can time. lets just do an input so we can see how long it take to type

Next let’s save the time again but we will call it end.

and in this print statement if we do end minus start that will give us the time passed.

So let’s run this in the terminal to see what it’s like

and lets type our put

it took 7.5 second.

Lets see if i can time it faster

There you have it that is how you time functions in python

#PythonMarathon #LearnPython #PythonTutorial


Sur cette page du site, vous pouvez voir la vidéo en ligne How to Time Functions in Python using time.time durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Python Marathon 31 août 2018, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 2,280 fois et il a aimé 29 téléspectateurs. Bon visionnage!