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
9
votes
4 answers

Output timing problem

the following code: String str1="asdfavaxzvzxvc"; String str2="werwerzsfaasdf"; Object c=str1; Object d=str2; System.out.println(c); long time1=System.currentTimeMillis(); for(int i=0;i<1000000000;i++){ if(c.equals(d)){ …
peeyush
  • 2,841
  • 3
  • 24
  • 43
9
votes
1 answer

Exact time of display: requestAnimationFrame usage and timeline

What I want to achieve is to detect the precise time of when a certain change appeared on the screen (primarily with Google Chrome). For example I show an item using $("xelement").show(); or change it using $("#xelement").text("sth new"); and then I…
gaspar
  • 898
  • 1
  • 13
  • 26
9
votes
1 answer

Why the dip in speed increase for generating 400,000,000 random numbers?

I'm generating around 400,000,000 (400 million) random numbers in parallel on an Intel i7 with 4 cores (8 threads hyperthreaded) on macOS with 8 GB RAM. However, I'm also generating 400,000,000 random numbers on a DigitalOcean server with 20 cores…
9
votes
2 answers

jQuery scope or race condition in AJAX/getJSON

I have a piece of jQuery code which invokes several getJSON() calls in quick succession: var table = $("table#output"); for (var i in items) { var thisItem = items[i]; $.getJSON("myService", { "itemID": thisItem }, function(json) { …
slim
  • 40,215
  • 13
  • 94
  • 127
9
votes
4 answers

Input with a timeout in C++

I want to have a program where the user have 10 seconds to enter the password. If the timer goes over 10 seconds, the program displays a message. My current code is this: #include #include #include int…
BoeNoe
  • 540
  • 1
  • 6
  • 19
9
votes
1 answer

How do I get the CLion debugger/console to tell me how many seconds my program took to run?

How do I time my C program in Clion? Is there an option I can use to to tell me how long long my program took to run? something like > finished in .003 seconds here is what I am referring to when I say debugger/console:
conor
  • 1,131
  • 1
  • 15
  • 20
9
votes
1 answer

Constant-time `if-else` in python

I'd like to know if there is an easy way (maybe a library) to write constant-time programs in Python. In particular, I'd like to be able to specify that an if-else flow must always last the same time whether the if condition is True or False. For…
synack
  • 1,699
  • 3
  • 24
  • 50
9
votes
2 answers

cudaMallocHost vs malloc for better performance shows no difference

I have gone through this site. From here I got that pinned memory using cudamallocHost gives better performance than cudamalloc. Then I use two different simple program and tested the execution time as using cudaMallocHost #include…
user3545251
  • 445
  • 3
  • 6
  • 15
8
votes
1 answer

How to use %%timeit cell magic and exclude setup code?

The %timeit magic supports execution in line mode and cell mode. Using the cell mode, invoked with %%timeit (note: two percent symbols), can be used to exclude some setup code from the measurement: %%timeit [-n -r [-t|-c] -q -p

-o]…

wim
  • 338,267
  • 99
  • 616
  • 750
8
votes
1 answer

Correct way of portably timing code using C++11

I'm in the midst of writing some timing code for a part of a program that has a low latency requirement. Looking at whats available in the std::chrono library, I'm finding it a bit difficult to write timing code that is…
Lucinda Rigetti
  • 427
  • 3
  • 10
8
votes
4 answers

Logical Clocks: Lamport Timestamps

I am currently trying to understand Lamport timestamps. Consider two processes P1 (producing events a1, a2,...) and P2 (producing events b1, b2,...). Let C(e) denote the Lamport timestamp associated with event an e. I created timestamps for each…
typeduke
  • 6,494
  • 6
  • 25
  • 34
8
votes
1 answer

OpenGL, measuring rendering time on gpu

I have some big performance issues here So I would like to take some measurements on the gpu side. By reading this thread I wrote this code around my draw functions, including the gl error check and the swapBuffers() (auto swapping is indeed…
elect
  • 6,765
  • 10
  • 53
  • 119
8
votes
5 answers

C# sub millisecond timing

Is there anywhere in C# to perform timing operations with sub millisecond accuracy? I'm putting timing code in my software and everything is being returned as 0ms. I would like to know if there is a way of getting even finer granularity. Addendum:…
deltanovember
  • 42,611
  • 64
  • 162
  • 244
8
votes
2 answers

Prevent context-switching in timed section of code (or measure then subtract time not actually spent in thread)

I have a multi-threaded application, and in a certain section of code I use a Stopwatch to measure the time of an operation: MatchCollection matches = regex.Matches(text); //lazy evaluation Int32 matchCount; //inside this bracket program should not…
David S.
  • 5,965
  • 2
  • 40
  • 77
8
votes
1 answer

pygame.time.set_timer confusion?

So, I have a problem, I don't fully understand the event that is needed to be given to a timer command anyway, it doesn't say anywhere online, to where I searched for hours. So I just used what most people seemed to be using 'USEREVENT + 1'. I'm not…
Bluetiger6001
  • 151
  • 2
  • 3
  • 9