0

why doesn't function time() work in Android?

returns always the same time while a program is executed from time import time def test(it): for i in range(it): var=i+1 time_0=time() test(100) time_1=time() time_ex=time_1 -time_0 print(time_0) print(time_1) print("The execution time is:",time_ex)

12th Sep 2016, 3:25 PM
c00lh@nd
c00lh@nd - avatar
3 Antworten
+ 1
time_1 and time_0 is always the same and time_ex=0.0
12th Sep 2016, 3:46 PM
c00lh@nd
c00lh@nd - avatar
0
Do you mean, time_0 and time_1 are always the same? Or time_ex is always the same?
12th Sep 2016, 3:44 PM
trueneu
trueneu - avatar
0
Your code seems okay to me. Maybe your test() function works just way too fast to register different time change. Try call it with a bigger argument. I'm not really sure, but it also can be an interpreter optimization side effect: you test() function doesn't have any side effects, it doesn't return any values, so probably the interpreter just doesn't call it at all. Try to return something and save it in a variable inside the main function. Yeah, I also tried time() in QPython3, and it works as expected.
14th Sep 2016, 2:04 PM
trueneu
trueneu - avatar