- 2

[ANSWERED] Runtime

How do I measure how long a program runs? --- I got a task to write a word-guessing program. It can just list all the characters, but it is known that the testing program that tests my program uses a word from a file with a certain name. The file is like a dictionary - seems that it is the set of all possible words of my language. So the question is -- which way the test server spends less time guessing the word - if I just list all the chars in alpabethical order or try to pre-guess using the file given?

7th Nov 2017, 7:33 PM
Alex Snaidars
Alex Snaidars - avatar
2 ответов
+ 2
import datetime a=datetime.datetime.now() #run code print("Time taken",datetime.datetime.now()-a)
7th Nov 2017, 11:21 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
- 2
import time start_time = time.time() main() print("--- %s seconds ---" % (time.time() - start_time))
7th Nov 2017, 8:08 PM
Alex Snaidars
Alex Snaidars - avatar