Questions tagged [timing]

timing is a numerical measurement of the how long it takes to execute an instruction or series of instructions

Timing is a numerical measurement of the how long it takes to execute an instruction or series of instructions. See also .

To get a better understanding of performance of a given code, it should be measured at several problem sizes and empirical orders of growth calculated.

1396 questions
22
votes
12 answers

Java performance timing library

I frequent wrap code in a System.nanoTime() pair in order to timing it. Something like: long start = System.nanoTime(); methodToBeTimed(); long elapsedTime = System.nanoTime() - start; There is any good timing library that helps with this…
dfa
  • 114,442
  • 31
  • 189
  • 228
22
votes
3 answers

Monotonic clock on OSX

CLOCK_MONOTONIC does not seem available, so clock_gettime is out. I've read in some places that mach_absolute_time() might be the right way to go, but after reading that it was a 'cpu dependent value', it instantly made me wonder if it is using…
Brett
  • 4,066
  • 8
  • 36
  • 50
21
votes
1 answer

How to estimate SQL query timing?

I'm trying to get an rough (order-of-magnitude) estimate of how long time the following query could take: mysql> EXPLAIN SELECT t1.col1, t1_col4 FROM t1 LEFT JOIN t2 ON t1.col1=t2.col1 WHERE col2=0 AND col3 IS…
qazwsx
  • 25,536
  • 30
  • 72
  • 106
19
votes
4 answers

What happens when QueryPerformanceCounter is called?

I'm looking into the exact implications of using QueryPerformanceCounter in our system and am trying to understand it's impact on the application. I can see from running it on my 4-core single cpu machine that it takes around 230ns to run. When I…
Matt Price
  • 43,887
  • 9
  • 38
  • 44
18
votes
4 answers

Executing code at regularly timed intervals in Clojure

What's the best way to make code run at regular intervals in Clojure ? I'm currently using java.util.concurrent.ScheduledExecutorService, but that's Java - is there a Clojure way of scheduling code to run at regular intervals, after a delay,…
Hendekagon
  • 4,565
  • 2
  • 28
  • 43
18
votes
2 answers

How can I get millisecond and microsecond-resolution timestamps in Python?

How do I get millisecond and microsecond-resolution timestamps in Python? I'd also like the Arduino-like delay() (which delays in milliseconds) and delayMicroseconds() functions. I read other answers before asking this question, but they rely on the…
Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
18
votes
1 answer

dynamic module creation

I'd like to dynamically create a module from a dictionary, and I'm wondering if adding an element to sys.modules is really the best way to do this. EG context = { a: 1, b: 2 } import types test_context_module = types.ModuleType('TestContext',…
intuited
  • 23,174
  • 7
  • 66
  • 88
18
votes
4 answers

Could a random sleep prevent timing attacks?

From Wikipedia In cryptography, a timing attack is a side channel attack in which the attacker attempts to compromise a cryptosystem by analyzing the time taken to execute cryptographic algorithms. Actually, to prevent timing attacks, I'm…
DrKey
  • 3,365
  • 2
  • 29
  • 46
17
votes
8 answers

What is the best way to measure Client Side page load times?

I'm looking to monitor the end user experience of our website and link that with timing information already logged on the server side. My assumption is that this will require javascript to to capture time stamps at the start of request…
Kam
  • 321
  • 1
  • 2
  • 10
17
votes
3 answers

jQuery Timed Event

Is it possible, using jQuery, to fire off an event to set a div tag's text after n. seconds? Thanks! George
George Johnston
  • 31,652
  • 27
  • 127
  • 172
16
votes
1 answer

How to use \timing in postgres

I want to know the time that it takes to execute a query in Postgres. I see a lot of answers that suggest to use \timing, but I'm newbie in Postgres and I don't know how to use it.
aName
  • 2,751
  • 3
  • 32
  • 61
16
votes
11 answers

How can I find the execution time of a section of my program in C?

I'm trying to find a way to get the execution time of a section of code in C. I've already tried both time() and clock() from time.h, but it seems that time() returns seconds and clock() seems to give me milliseconds (or centiseconds?) I would like…
Stephen Booher
  • 6,522
  • 4
  • 34
  • 50
15
votes
4 answers

requestAnimationFrame [now] vs performance.now() time discrepancy

Assumptions: rAF now time is calculated at the time the set of callbacks are all triggered. Therefore any blocking that happens before the first callback of that frame is called doesn't affect the rAF now and it's accurate--at least for that first…
15
votes
3 answers

Can the execution of statements in Python be delayed?

I want it to run the first line print 1 then wait 1 second to run the second command print 2, etc. Pseudo-code: print 1 wait(1 seconds) print 2 wait(0.45 seconds) print 3 wait(3 seconds) print 4
rectangletangle
  • 50,393
  • 94
  • 205
  • 275
15
votes
3 answers

Using bash variables in Makefile

I want to use the bash timing variables in my makefile for example in my terminal I can do this and it works MY_TIME=$SECONDS echo $MY_TIME but when I write this on my makefile it does not work how can I use these two lines in my make file? this…
Lily
  • 816
  • 7
  • 18
  • 38
1 2
3
92 93