time-measurement

Timing vs the “as-if” rule

只谈情不闲聊 提交于 2021-02-07 17:54:28
问题 There is a great question about the "as-if" rule in general, but I wonder if there are any excpetions when it comes to measuring time. Consider this (taken from here slightly modified): using std::chrono; auto begin = steady_clock::now(); auto result = some_lengthy_calculation(some_params); auto end= std::chrono::steady_clock::now(); std::cout << "Time diff = " << duration_cast<microseconds>(end - begin).count() <<std::endl; std::cout << "Result = " << result; The compiler is allowed to apply

How do I measure time per thread in C?

戏子无情 提交于 2019-12-24 14:22:30
问题 I am working on a code with multiple number of threads and I want to print the time it took for me to complete task I assigned the i-th thread to do. Meaning I want to print the time each thread took to be done with the doSomeThing function int main(int argc, char *argv[]){ // ... i=0; while (i < NumberOfThreads){ check = pthread_create(&(id_arr[i]), NULL, &doSomeThing, &data); i++; } // ... } void* doSomeThing(void *arg){ // ... } if I add gettimeofday(&thread_start, NULL) before the pthread

How to measure function running time in Qt?

笑着哭i 提交于 2019-12-22 01:32:21
问题 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 library's test case, time is measured in another way: ... clock_t start = clock(); // call hashing function clock_t finish = clock(); time = ((double)finish - start) / CLOCKS_PER_SEC; ... I am calling the function exactly as they call in their test

ARM performance counters vs linux clock_gettime

微笑、不失礼 提交于 2019-12-21 05:14:18
问题 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 provided by the co-processor of ARM. The counter increment every one processor cycle. ( based on this question of stackoverflow and this) I compile the program with -O0 flag ( since I don't want any reordering or optimization done) The time I measure

C++ Time measurement of functions

随声附和 提交于 2019-12-08 06:24:05
问题 I need to measure the time of a C++ programs, especially the overall running time of some recursive functions. There are a lot of function calls inside other functions. My first thought was to implement some time measurements functions in the actual code. The problem with gprof is, that it prints out the time of class operators of a datatype, but i only need the infomartion about the functions and "-f func_name prog_name" wont work. So, what is the most common way in science to measure time

How to measure function running time in Qt?

纵然是瞬间 提交于 2019-12-04 19:26:28
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 library's test case, time is measured in another way: ... clock_t start = clock(); // call hashing function clock_t finish = clock(); time = ((double)finish - start) / CLOCKS_PER_SEC; ... I am calling the function exactly as they call in their test case. But I am getting a twice bigger number (twice slower). Why? How to measure function running time

ARM performance counters vs linux clock_gettime

点点圈 提交于 2019-12-03 20:53:58
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 provided by the co-processor of ARM. The counter increment every one processor cycle. ( based on this question of stackoverflow and this ) I compile the program with -O0 flag ( since I don't want any reordering or optimization done) The time I measure with the performance counters is 583833498 ( cycles ) / 666.666687 MHz = 875750.221 (microseconds)

Measure executing time on ARM Cortex-A8 using hardware counter

空扰寡人 提交于 2019-11-30 11:41:19
问题 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 program execution time in ARM Cortex-A8 processor? I loaded the kernel module to allow reading the register values in user mode. I am using the following program to test the counter: static inline unsigned int get_cyclecount (void) { unsigned int value

Measure executing time on ARM Cortex-A8 using hardware counter

旧街凉风 提交于 2019-11-30 00:58:43
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 program execution time in ARM Cortex-A8 processor? I loaded the kernel module to allow reading the register values in user mode. I am using the following program to test the counter: static inline unsigned int get_cyclecount (void) { unsigned int value; // Read CCNT Register asm volatile ("MRC p15, 0, %0, c9, c13, 0\t\n": "=r"(value)); return value; }

How to measure the time that a piece of code takes to execute?

独自空忆成欢 提交于 2019-11-29 04:29:46
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() - startTime)/CLOCKS_PER_SEC; What if the program is multithreaded and context switches occur within the part which I want to measure? How would I measure the time that my code takes to execute excluding time spent on other threads? Even if there are tools that do it, I would very much like to know how they're doing it. There are different ways to measure how long code