marlon
marlon

Reputation: 7723

Why isn't this timing of program right?

start = time.time()

process_file(builder_configs.data_directory_id)

end = time.time()

print("Time spent: ", str(timedelta(minutes=(end - start))))

At the end of the running the program, it shows:

Time spent:  1 day, 12:12:41.348290

This is totally wrong. It runs and ended within at most 1 hour, but it shows 1 day? How to interpret this?

Upvotes: 0

Views: 33

Answers (1)

Daniel Giger
Daniel Giger

Reputation: 2553

As Miloslaw Smyk commented, you want to set the seconds, not the minutes because time.time() measures seconds. You can fix this by replacing the last line with this:

print("Time spent: ", str(timedelta(seconds=(end - start))))

Upvotes: 1

Related Questions