Name |
Second |
Millisecond |
Microsecond |
Nanosecond |
Abbrev. |
1s |
1ms |
1us (or µs) |
1ns |
Duration |
1.0e0s |
1.0e-3s |
1.0e-6s |
1.0e-9s |
Same as |
1 heartbeat |
1 bullet-foot |
1 light-block |
1 light-foot 1 cpu clock cycle 1 cpu instruction |
1s |
100ms |
10ms |
1ms |
100us |
10us |
1us |
100ns |
10ns |
1ns |
Waiting for the human being |
Reading or writing from CD, DVD, floppy Typical remote network latency |
Reading or writing from Hard Drive |
Typical local network latency fopen |
cout cin |
OS call |
sqrt sin cos pow malloc new |
/, % CALL |
+, -, * &, |, ^, <<, >> [i] |
int do_silly_work(int a,int b) {Adding one word, "inline", tells the compiler to insert the code for do_silly_work inside foo. Once it's there, the compiler's optimizer then has a chance to notice that a and b are both *constants*, so it can do the silly work at compile time. Overall, foo now takes just 4ns, a 5x speedup!
return a+b/a;
}
int foo(void) {
return do_silly_work(7,13);
}
inline int do_silly_work(int a,int b) {"inline" is really handy. I put "inline" in front of most of my short functions.
return a+b/a;
}
int foo(void) {
return do_silly_work(7,13);
}