Tempo datetime.datetime.now()

Asked

Viewed 339 times

4

I’m making a script where I measure the performance of a query in a database. The code is as follows::

start = datetime.datetime.now()

//CONSULTA AQUI

end = datetime.datetime.now()

print "Time taken: %s"%(end - start, )

The program returned the following result in the first query: Time Taken: 0:00:00.000593 In another query presented the following result: Time Taken: 0:00:31.833141

The two results are being given in milliseconds or seconds?

  • Related (or duplicated?): Measuring the run time of a function

  • didn’t understand the question @jbueno

  • The first consultation took less than 1 thousandth of a second, the second took 31 seconds and a few thousandths. After the point are the thousandths.

  • Thank you, guys!

1 answer

2


Only the segundo(Time taken: 0:00:31.833141) is in seconds. The first is in milliseconds.

  • So in this case, I can say that the first is 0.000593 second, right?

  • Exactly, but it would be better for you to say it was less than a thousandth of a second than to say it was 0.000593 seconds

  • Ah, but it’s because I’m working with statistical data in spreadsheet and I need to put the precise number, got it?

  • Oh yes, I get it. Good luck on the project!

  • Thank you, TCC project :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.