Is there any way when I run time
command with option -c
on my program it show me 0 secs under user
section? Is this what we'd call that the program is not CPU bound?
I have a program for which I'm always getting 0.01 secs. I've done some optimizations, but still the same. I've got this program run time from around 8secs down to 0.01 secs but I can't reduce further.
Is this something to do with sampling interval in context of activity time capture?
Asked
Active
Viewed 113 times
-3

Diwakar Sharma
- 415
- 1
- 9
- 26
-
2I guess one is into deceiving oneself. Very odd behaviour – Ed Heal Nov 09 '13 at 08:41
-
5The only way your program is going to take 0 seconds is if you don't run the damn thing. What kind of question is this? – Chris Hayes Nov 09 '13 at 08:48
-
'run time from around 8secs down to 0.01 secs' - what did it do before the optimization, and what did it do after? – Martin James Nov 09 '13 at 08:49
-
@MartinJames Using a trie gave me so much time gain. – Diwakar Sharma Nov 09 '13 at 09:27
-
@ChrisHayes That is why I said 'LOOK TO BE' .. there is a difference. Which can be due to being so small in decimal places that it is reported as 0. – Diwakar Sharma Nov 09 '13 at 09:29
1 Answers
1
No, "not CPU bound" means that the application's performance is constrained by something else, typically by the amount of I/O it is doing. It does not refer to any specific running time, it just means that the application is sitting waiting for I/O to complete or something most of the time.
Since time
, on Linux at least, shows system time as well as user time, and user time is a measure of how much your code is actually running, as opposed to the OS kernel's code, if your user time is much lower than the wall clock time that is crude evidence that your program is "not CPU bound".
It is a strange question. But I guess it does not need answering now that you know that you have misunderstood "not CPU bound".

Robin Green
- 32,079
- 16
- 104
- 187
-
Ok.. Suppose if I'm reading characters from stdin using getchar(). I don't know how many more characters are yet to arrive. So as per definition of CPU bound , I can't make this scenario non-CPU bound , right? because I'll have to keep looping till EOF. – Diwakar Sharma Nov 09 '13 at 09:34
-
@DiwakarSharma if you are reading from the user it is already non-CPU bound in that part of the program, because you are limited by the speed of the user's typing, not the speed of the CPU. If you might be reading from a file redirected into stdin, you should consider some more efficient block I/O method of reading data from stdin. – Robin Green Nov 09 '13 at 09:37
-
Exactly as you said , I'm redirecting a file to stdin like ./a.out < file – Diwakar Sharma Nov 09 '13 at 09:40
-