Questions tagged [time-measurement]
59 questions
188
votes
16 answers
Python speed testing - Time Difference - milliseconds
What is the proper way to compare 2 times in Python in order to speed test a section of code? I tried reading the API docs. I'm not sure I understand the timedelta thing.
So far I have this code:
from datetime import datetime
tstart =…

BuddyJoe
- 69,735
- 114
- 291
- 466
30
votes
4 answers
How to measure program execution time in ARM Cortex-A8 processor?
I'm using an ARM Cortex-A8 based processor called as i.MX515. There is linux Ubuntu 9.10 distribution. I'm running a very big application written in C and I'm making use of gettimeofday(); functions to measure the time my application…

HaggarTheHorrible
- 7,083
- 20
- 70
- 81
14
votes
1 answer
How to measure multithreaded process time on a multitasking environment?
Since I am running performance evaluation tests of my multithreaded program on a (preemptive) multitasking, multicore environment, the process can get swapped out periodically. I want to compute the latency, i.e., only the duration when the process…

amit kumar
- 20,438
- 23
- 90
- 126
10
votes
4 answers
Measuring the execution time in multithreading environment
I have an application that uses Task (TPL) objects for asynchronous execution.
The main thread waits for a trigger (some TCP packet) and then executes several tasks. What I want to do is to measure the time spent in the tasks.
Take a look at the…

Kornelije Petak
- 9,412
- 15
- 68
- 96
7
votes
2 answers
Measure executing time on ARM Cortex-A8 using hardware counter
I'm using a Exynos 3110 processor (1 GHz Single-core ARM Cortex-A8, e.g. used in the Nexus S) and try to measure execution times of particular functions. I have an Android 4.0.3 running on the Nexus S. I tried the method from
[1] How to measure…

user1207228
- 91
- 1
- 3
7
votes
4 answers
How to measure the time that a piece of code takes to execute?
Suppose I want to measure the time that a certain piece of code takes. For that I would normally do something like this
clock_t startTime = clock();
//do stuff
//do stuff
//do stuff
//do stuff
float secsElapsed = (float)(clock() -…

Armen Tsirunyan
- 130,161
- 59
- 324
- 434
7
votes
1 answer
Can we use $_SERVER['REQUEST_TIME_FLOAT'] to get a reliable process time?
I see every one suggests using a variable such as
$start_time = microtime(TRUE);
on top of the script, and then on the final line we do:
$process_time = microtime(TRUE) - $start_time;
My question is, can we reliably use…

J. Doe
- 812
- 1
- 15
- 33
6
votes
1 answer
Measure long elapsed time (with reboots) on Android
I need to measure long elapsed time on Android and there may be device reboots in between.
From what I've understand, System.nanoTime() is resetted every time the device reboot, and System.currentTimeMillis() is unreliable because user can change…

dmarcato
- 872
- 8
- 16
5
votes
2 answers
How to measure function running time in Qt?
I am calling argon2 - memory intensive hashing function in Qt and measuring its running time:
...
QTime start = QTime::currentTime();
// call hashing function
QTime finish = QTime::currentTime();
time = start.msecsTo(finish) / 1000.0;
...
In argon2…

Bobur
- 545
- 1
- 6
- 21
5
votes
1 answer
Measure C code execution time (Linux)
I want to measure the execution time of a c-code segment using Linux.
I take one timestamps at the beginning of the code segment and one at the end.
But I don't know how to protect the code against IRQs and context switches to high prior tasks. The…

Fox0815
- 53
- 1
- 3
4
votes
2 answers
Timing vs the "as-if" rule
There is a great question about the "as-if" rule in general, but I wonder if there are any exceptions when it comes to measuring time.
Consider this (taken from here slightly modified):
using std::chrono;
auto begin = steady_clock::now();
auto…

463035818_is_not_an_ai
- 109,796
- 11
- 89
- 185
4
votes
2 answers
clock_gettime might be very slow even using VDSO
I'm using CentOS Linux release 7.3.1611 on Intel(R) Xeon(R) CPU E5-2667 v4 @ 3.20GHz
During tests of my userspace application, I have noticed that clock_gettime(CLOCK_MONOTONIC, &ts) may take up to 5-6 microseconds instead of ~23 nanoseconds in…

Konstantin Utkin
- 478
- 1
- 5
- 16
4
votes
2 answers
ARM performance counters vs linux clock_gettime
I am using a Zynq chip on a development board ( ZC702 ) ,
which has a dual cortex-A9 MPCore at 667MHz and comes with a Linux kernel 3.3
I wanted to compare the execution time of a program so first a used
clock_gettime and then used the counters…

akarapatis
- 852
- 8
- 18
4
votes
2 answers
Measuring parallel computation time for interdependent threads
I have a question concerning runtime measurements in parallel programs (I used C++ but I think the question is more general).
Some short explanations: 3 threads are running parallel (pthread), solving the same problem in different ways. Each thread…

Martin
- 328
- 1
- 6
3
votes
1 answer
How can I measure the time it takes to complete a batch of jobs in Sun Grid Engine?
I'm using Sun Grid Engine to run a batch of jobs on Amazon Web Services EC2 nodes and I'd like to measure the wall time it takes to complete the whole batch. I'm fine with either from the time of submission to the time the queue is empty, or from…

David
- 444
- 2
- 9