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
55
votes
2 answers

What is the difference between CLOCK_MONOTONIC & CLOCK_MONOTONIC_RAW?

According to the Linux man page under Ubuntu CLOCK_MONOTONIC Clock that cannot be set and represents monotonic time since some unspecified starting point. CLOCK_MONOTONIC_RAW (since Linux 2.6.28; Linux-specific) Similar to …
hookenz
  • 36,432
  • 45
  • 177
  • 286
53
votes
5 answers

Why is Collections.sort() much slower than Arrays.sort()?

I tried to do a test, regarding Collection.sort() and Arrays.sort(). In the test, I created an array of ints of length 1e5 100 times, which contained random numbers from 1 to 1e5. I also created a list of type Integer, which contained the same…
Mooncrater
  • 4,146
  • 4
  • 33
  • 62
51
votes
4 answers

Getting an accurate execution time in C++ (micro seconds)

I want to get an accurate execution time in micro seconds of my program implemented with C++. I have tried to get the execution time with clock_t but it's not accurate. (Note that micro-benchmarking is hard. An accurate timer is only a small part…
user3323616
  • 513
  • 1
  • 4
  • 4
48
votes
2 answers

How can we easily time function calls in elixir?

How can we easily time function calls in Elixir? Is there any hidden switch in IEx to enable this?
Charles Okwuagwu
  • 10,538
  • 16
  • 87
  • 157
37
votes
5 answers

differences between "d = dict()" and "d = {}"

$ python2.7 -m timeit 'd={}' 10000000 loops, best of 3: 0.0331 usec per loop $ python2.7 -m timeit 'd=dict()' 1000000 loops, best of 3: 0.19 usec per loop Why use one over the other?
tshepang
  • 12,111
  • 21
  • 91
  • 136
33
votes
9 answers

Writing a java annotation for timing method call

I want to write a java annotation which times the method call. something like this: @TimeIt public int someMethod() { ... } and when this method is invoked, it should output on console how long this method took I know how to do it in python, this…
roopesh
  • 1,636
  • 2
  • 13
  • 16
32
votes
1 answer

Get evaluation timings in GHCi

I have a relatively slow procedure (aptly named slow), and I would like to do something like time $ slow [1,2,3,4,5] in the console (REPL) to get the time, instead of having to compile the program and then run time. Can this be done?
Christian Neverdal
  • 5,655
  • 6
  • 38
  • 93
31
votes
4 answers

Measuring time taken by a function: clock_gettime

I am trying to measure how long a function takes. I have a little issue: although I am trying to be precise, and use floating points, every time I print my code using %lf I get one of two answers: 1.000... or 0.000... This leads me to wonder if my…
Jary
  • 397
  • 1
  • 5
  • 7
31
votes
6 answers

Timing in JS - multiple setIntervals running at once and starting at the same time?

Let's say I have a function: myFunc = function(number) { console.log("Booyah! "+number); } And I want it to run on a set interval. Sounds like I should use setInterval, huh! But what if I want to run multiple intervals of the same function, all…
Joshua Soileau
  • 2,933
  • 9
  • 40
  • 51
29
votes
5 answers

How to time a function in milliseconds without boost::timer

I am using boost 1.46 which does not include boost::timer, What other way can I time my functions. I am currently doing this: time_t now = time(0); time_t after = time(0); cout << after - now << endl; but it just gives the answer in…
Aly
  • 15,865
  • 47
  • 119
  • 191
28
votes
5 answers

Are Sql Triggers synchronous or asynchronous?

I have a table that has an insert trigger on it. If I insert in 6000 records into this table in one insert statement from a stored procedure, will the stored procedure return before the insert trigger completes? Just to make sure that I'm thinking…
Miles
  • 5,646
  • 18
  • 62
  • 86
24
votes
9 answers

How to program a real-time accurate audio sequencer on the iphone?

I want to program a simple audio sequencer on the iphone but I can't get accurate timing. The last days I tried all possible audio techniques on the iphone, starting from AudioServicesPlaySystemSound and AVAudioPlayer and OpenAL to AudioQueues. In…
Walchy
  • 1,150
  • 3
  • 11
  • 18
24
votes
2 answers

Java 8 odd timing/memory issue

I've run across a rather strange problem that I can create when running Java 8. The problem presents itself as if some sort of timing error is happening within the JVM itself. It is intermittent in nature, but easily reproducible (at least within…
bcothren
  • 243
  • 1
  • 7
24
votes
3 answers

How accurate is Thread.sleep?

I'm studying computer hardware where we learn that using a hardware timer gets more accurate results than a software delay. I've written a software delay in assembly for 1 millisecond and I can start a process that repeats every millisecod using…
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
22
votes
4 answers

c++ Implementing Timed Callback function

I want to implement some system in c++ so that I can call a function and ask for another function to be called in X milliseconds. Something like this: callfunctiontimed(25, funcName); 25 being the amount of milliseconds before the function should…
DavidColson
  • 8,387
  • 9
  • 37
  • 50
1
2
3
92 93