From dfccb60a75643a4db345f8bfa3ad6f9fbc5560e6 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 20 Mar 2018 02:30:24 +0000 Subject: [PATCH] Fix -O option handling Fast syscalls usually take less than a microsecond of system cpu time nowadays, making -O option almost useless. * count.c (call_summary_pers): Avoid negative time counts. * tests/count.test: Check it. * NEWS: Mention it. --- NEWS | 1 + count.c | 2 ++ tests/count.test | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/NEWS b/NEWS index 002af107..ee9e2457 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ Noteworthy changes in release ?.?? (????-??-??) * Bug fixes * Fixed build on m68k. * Fixed v4l2 pixelformat decoding on big-endian architectures. + * Fixed -O option. Noteworthy changes in release 4.21 (2018-02-13) =============================================== diff --git a/count.c b/count.c index b4145364..5d93371d 100644 --- a/count.c +++ b/count.c @@ -150,6 +150,8 @@ call_summary_pers(FILE *outf) continue; tv_mul(&dtv, &overhead, counts[i].calls); tv_sub(&counts[i].time, &counts[i].time, &dtv); + if (counts[i].time.tv_sec < 0 || counts[i].time.tv_usec < 0) + counts[i].time.tv_sec = counts[i].time.tv_usec = 0; call_cum += counts[i].calls; error_cum += counts[i].errors; tv_add(&tv_cum, &tv_cum, &counts[i].time); diff --git a/tests/count.test b/tests/count.test index a9752c09..39332a9a 100755 --- a/tests/count.test +++ b/tests/count.test @@ -50,8 +50,12 @@ grep_log() } grep_log ' *[^ ]+ +0\.0[^n]*nanosleep' -c +grep_log ' *[^ ]+ +0\.0[^n]*nanosleep' -c -O1 grep_log ' *[^ ]+ +0\.0[^n]*nanosleep' -c -enanosleep +grep_log ' *[^ ]+ +0\.0[^n]*nanosleep' -c -O1 -enanosleep grep_log ' *[^ ]+ +(1\.[01]|0\.99)[^n]*nanosleep' -cw +grep_log ' *[^ ]+ +(1\.[01]|0\.99)[^n]*nanosleep' -cw -O1 grep_log '100\.00 +(1\.[01]|0\.99)[^n]*nanosleep' -cw -enanosleep +grep_log '100\.00 +(1\.[01]|0\.99)[^n]*nanosleep' -cw -O1 -enanosleep exit 0 -- 2.50.1