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
14
votes
5 answers

Java equivalent of setInterval in javascript

Basically I want a function to be called every say, 10 milliseconds. How can I achieve that in Java?
hasen
  • 161,647
  • 65
  • 194
  • 231
14
votes
3 answers

How do I achieve very accurate timing in Swift?

I am working on a musical app with an arpeggio/sequencing feature that requires great timing accuracy. Currently, using `Timer' I have achieved an accuracy with an average jitter of ~5ms, but a max jitter of ~11ms, which is unacceptable for fast…
PlateReverb
  • 654
  • 1
  • 7
  • 21
14
votes
4 answers

Erlang/OTP - Timing Applications

I am interested in bench-marking different parts of my program for speed. I having tried using info(statistics) and erlang:now() I need to know down to the microsecond what the average speed is. I don't know why I am having trouble with a script I…
BAR
  • 15,909
  • 27
  • 97
  • 185
14
votes
5 answers

Constant time equals

To prevent timing attacks, a constant time equals is sometimes needed. There's MessageDigest.isEqual not documented to be a constant time method and guava HashCode.equals and others. All of them do something like boolean areEqual = true; for (int i…
maaartinus
  • 44,714
  • 32
  • 161
  • 320
14
votes
8 answers

Microsecond accurate (or better) process timing in Linux

I need a very accurate way to time parts of my program. I could use the regular high-resolution clock for this, but that will return wallclock time, which is not what I need: I needthe time spent running only my process. I distinctly remember seeing…
rix0rrr
  • 9,856
  • 5
  • 45
  • 48
14
votes
3 answers

Javascript run loop for specified time

I have a function that interfaces with a telephony program and calls people. I want to know, is there a method that I can use to call folks for a certain amount of time? I'd like to run a loop like this: while (flag = 0) { …
TheMonarch
  • 577
  • 1
  • 5
  • 19
13
votes
2 answers

Precisely measure execution time of code in thread (C#)

I'm trying to measure the execution time of some bits of code as accurately as possible on a number of threads, taking context switching and thread downtime into account. The application is implemented in C# (VS 2008). Example: public void…
xxbbcc
  • 16,930
  • 5
  • 50
  • 83
13
votes
2 answers

Mathematica execution-time bug: symbol names

There is a strange bug that has been in Mathematica for years, at least since version 5.1, and persisting through version 7. Module[{f, L}, L = f[]; Do[L = f[L, i], {i, 10^4}]] // Timing {0.015, Null} Module[{weirdness, L}, L = weirdness[]; …
Mr.Wizard
  • 24,179
  • 5
  • 44
  • 125
13
votes
1 answer

Why is len() so slow?

I'm running the following code in an ipython session: # This call is slow, but that is expected. (It loads 3 GB of data.) In [3]: arc, arc_sub, upls, go = foo_mod.ready_set() # This call is also slow, as `upls` is huge. In [4]: upls = list(upls) #…
Thanatos
  • 42,585
  • 14
  • 91
  • 146
13
votes
9 answers

Testing your code for speed?

I'm a total newbie, but I was writing a little program that worked on strings in C# and I noticed that if I did a few things differently, the code executed significantly faster. So it had me wondering, how do you go about clocking your code's…
Ashlocke
  • 1,477
  • 4
  • 15
  • 13
12
votes
3 answers

%timeit equivalent in code

The magic command %timeit is great to measure code execution times in an interactive way. However, I want to get the result of %timeit in order to plot the results. timeit.timeit allows this as well, but does not have the automatic scaling of the…
Mark van der Wilk
  • 777
  • 1
  • 9
  • 18
12
votes
2 answers

What exactly are fractional seconds returned by Python time.perf_counter()?

This is probably a dumb/obvious question, but just want to make sure my hunches are correct. I'm doing some basic performance timing in a Python3 script using time.perf_counter() like so: start = time.perf_counter() # some time consuming operation…
baisang
  • 414
  • 6
  • 13
12
votes
3 answers

JavaScript event sequence

Some events in JavaScript fire before others. For example, with an input element, the keydown and keypress events fire first. Then, if the return value from those was not false, the input.value is updated. Then, the keyup event fires. Is there a web…
Stephen Sorensen
  • 11,455
  • 13
  • 33
  • 46
11
votes
3 answers

Windows 7 timing functions - How to use GetSystemTimeAdjustment correctly?

I ran some tests using the GetSystemTimeAdjustment function on Windows 7, and got some interesting results which I cannot explain. As fas as I understand, this method should return if the system time is synchronized periodically and if it is, at…
fdlm
  • 614
  • 1
  • 5
  • 14
11
votes
5 answers

Linux, need accurate program timing. Scheduler wake up program

I have a thread running on a Linux system which i need to execute in as accurate intervals as possbile. E.g. execute once every ms. Currently this is done by creating a timer with timerfd_create(CLOCK_MONOTONIC, 0) , and then passing the desired…
K_scheduler
  • 143
  • 1
  • 4