After all, what should I use when I want to measure the time accurately in C language?

Asked 1 years ago, Updated 1 years ago, 101 views

We are currently programming using CUDA.
Therefore, I would like to measure the processing time on the CPU side accurately (milliseconds or microseconds).
There are functions for measuring time, but which one should I use after all?

  • clock()
  • GetTickCount()
  • QueryPerformanceCounter()

c cuda

2022-09-30 21:19

1 Answers

"It depends on how you interpret the wording ""processing time""

"

1. Time elapsed from job start to end (CPU may be playing during that time)
The QueryPerformanceCounter should not be troublesome.
GetTickCount also returns this value.

2. Time the CPU is actually running from the start to the end of the job
consists of three main steps:
- Host Memory ->Data Transfer Time to GPU
- GPGPU Calculation Time
- GPU ->Data transfer time to host memory
During this time, the CPU is barely running (because DMAC is working hard).
I don't feel very happy even if I measure it.
clock is this way, but the resolution is not very high, so GetProcessTime would be good.


2022-09-30 21:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.