Questions tagged [cpu-time]

103 questions
18
votes
4 answers

Measuring CPU time in c++

If I had the following code clock_t t; t = clock(); //algorithm t = clock() - t; t would equal the number of ticks to run the program. Is this the same is CPU time? Are there any other ways to measure CPU time in C++? OS -- Debian GNU/Linux I am…
user3025872
  • 181
  • 1
  • 1
  • 4
15
votes
2 answers

Measuring elapsed CPU time in Julia

Many scientific computing languages make a distinction between absolute time (wall clock) and CPU time (processor cycles). For example, in Matlab we have: >> tic; pause(1); toc Elapsed time is 1.009068 seconds. >> start = cputime; pause(1); elapsed…
eds
  • 381
  • 1
  • 2
  • 8
11
votes
3 answers

c++ practical computational complexity of SQRT()

What is the difference in CPU cycles (or, in essence, in 'speed') between x /= y; and #include x = sqrt(y); EDIT: I know the operations aren't equivalent, I'm just arbitrarily proposing x /= y as a benchmark for x = sqrt(y)
Matt Munson
  • 2,903
  • 5
  • 33
  • 52
8
votes
2 answers

SQL Server Query Tuning: why CPU Time is higher than Elapsed Time ? Are they relevant to set operation?

I have two query to filter some userid depend on question and its answers. Scenario Query A is (the original version): SELECT userid FROM mem..ProfileResult WHERE ( ( QuestionID = 4 AND QuestionLabelID = 0 AND AnswerGroupID = 4 …
Jeff Chen
  • 736
  • 1
  • 8
  • 20
7
votes
2 answers

Is idle thread taking CPU execute time in Java Executors?

When I have this code in an application: Executors.newFixedThreadPool(4); but I never use this thread pool. Will the idle threads consume CPU time? If so - why?
Ryanqy
  • 8,476
  • 4
  • 17
  • 27
7
votes
7 answers

How can I measure CPU time in C++ on windows and include calls of system()?

I want to run some benchmarks on a C++ algorithm and want to get the CPU time it takes, depending on inputs. I use Visual Studio 2012 on Windows 7. I already discovered one way to calculate the CPU time in Windows: How can I measure CPU time and…
Niels Thole
  • 117
  • 1
  • 5
6
votes
1 answer

determine how much resource used by a php script (cpu percentage and memory)

I'm currently using xhprof library forked by tideways.io for profiling myscript.php execution. From xhprof, i can get the walltime, cputime, memoryusage, and peakmemoryusage. I'm try to benchmark a symfony console - so i add TIDEWAYS_ENABLE() on its…
5
votes
3 answers

How to capture wall-clock time and CPU time in a Python variable using bash builtin 'time'?

I am working on a Python script that is going to be run in the command line. The idea is to get a command from the user, run it and then provide the wall-clock time and the CPU time of the command provided by the user. See code below. #!/usr/bin/env…
Tesla001
  • 493
  • 1
  • 5
  • 7
4
votes
1 answer

Does JMH calculate operations per time unit based on CPU time or on wall-clock time?

Considering the default usage of the JMH, I would like to make sure which type of time JMH bases its measurements on: CPU time or Wall-clock. I tried looking into the JMH official samples (https://openjdk.java.net/projects/code-tools/jmh/),…
4
votes
1 answer

Reliable cross-platform way to obtain the method time in Java

This question is not about benchmark. I have a java thread cycle that should to operate close to a period time T: public class MyRunnable implements Runnable { private final long period = 10000L; //period T, in this case 10 secs public…
Duloren
  • 2,395
  • 1
  • 25
  • 36
4
votes
1 answer

How to find CPU and IO time?

We have a REST based service that is calling external API and get the response back from that API. I was filing Capacity request here to make sure our boxes can handle the traffic when we host the service. So the Capacity guys have asked me - Any…
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
3
votes
1 answer

Odd discrepancy in CPU vs Wall time measurements with malloc

Answer: user and kernel cpu time is measured separately, be careful! EDIT: pTimes is now reset to zero between each benchmark, but the results got weirder! With the end goal of fiddling with my own custom memory management schemes, I made a simple…
FShrike
  • 323
  • 1
  • 10
3
votes
2 answers

Should CPU time always be identical between executions of same code?

My understanding of CPU time is that it should always be the same between every execution, on a same machine. It should require an identical amount of cpu cycles every time. But I'm running some tests now, of executing a basic echo "Hello World",…
Erndob
  • 2,512
  • 20
  • 32
3
votes
1 answer

real time vs. cpu time performance measure

I'm trying to do some performance measures in c++ by measuring the real elapsed time in milliseconds vs. the cpu time in milliseconds. This is how my code looks like: auto start = std::chrono::high_resolution_clock::now(); unsigned begin =…
Ben
  • 4,486
  • 6
  • 33
  • 48
3
votes
3 answers

Getting CPU time spent on process vs. World time spent on process problem c++

I am using two different ways of obtaining time clock() and getLocalTime() because I Want both the CPU time spent on my process AND the wall clock time spent on this process. Currently I do this: printf("CPU Time: %gms \n", (((double)(finish-start))…
Pete L
  • 61
  • 1
  • 3
1
2 3 4 5 6 7