Fix a scaling error in the new time command
This commit is contained in:
parent
3b3b8faf68
commit
6c89c01cf5
@ -1012,10 +1012,14 @@ o time "<command>"
|
|||||||
|
|
||||||
nsh> time "sleep 2"
|
nsh> time "sleep 2"
|
||||||
|
|
||||||
2.0001 sec
|
2.0100 sec
|
||||||
|
nsh>
|
||||||
|
|
||||||
The addition 100 microseconds in this example is the additional overhead
|
The additional 10 millseconds in this example is due primarily to the
|
||||||
of the time command execution itself which is included in the total.
|
quantization error in the timing (this setup used a 10 millisecond
|
||||||
|
periodic system timer). Other sources of error could include the
|
||||||
|
additional overhead of the time command execution itself which is
|
||||||
|
included in the total.
|
||||||
|
|
||||||
Notice that:
|
Notice that:
|
||||||
|
|
||||||
@ -1023,9 +1027,16 @@ o time "<command>"
|
|||||||
sleep [3:100]
|
sleep [3:100]
|
||||||
|
|
||||||
0.0000 sec
|
0.0000 sec
|
||||||
|
nsh>
|
||||||
|
|
||||||
Since the sleep command is executed in background, the sleep command
|
Since the sleep command is executed in background, the sleep command
|
||||||
completes almost immediately.
|
completes almost immediately. As opposed to the following where the
|
||||||
|
time command is run in background with the sleep command:
|
||||||
|
|
||||||
|
nsh> time "sleep 2" &
|
||||||
|
time [3:100]
|
||||||
|
nsh>
|
||||||
|
2.0100 sec
|
||||||
|
|
||||||
o unset <name>
|
o unset <name>
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ int cmd_time(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
|
|
||||||
diff.tv_nsec = end.tv_nsec - start.tv_nsec;
|
diff.tv_nsec = end.tv_nsec - start.tv_nsec;
|
||||||
nsh_output(vtbl, "\n%lu.%04lu sec\n", (unsigned long)diff.tv_sec,
|
nsh_output(vtbl, "\n%lu.%04lu sec\n", (unsigned long)diff.tv_sec,
|
||||||
(unsigned long)diff.tv_nsec / 10000000);
|
(unsigned long)diff.tv_nsec / 100000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user