]> granicus.if.org Git - sysstat/commitdiff
Small code optimization
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 30 Jan 2021 15:45:37 +0000 (16:45 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 30 Jan 2021 15:45:37 +0000 (16:45 +0100)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sadf.c
sar.c

diff --git a/sadf.c b/sadf.c
index 025d44fc861805edd1c7fadd1bdc1bc42028b6e4..4982197a4bd0552076eee879eb0723a2fa99cd8a 100644 (file)
--- a/sadf.c
+++ b/sadf.c
@@ -681,9 +681,6 @@ int generic_write_stats(int curr, int use_tm_start, int use_tm_end, int reset,
                cross_day = TRUE;
        }
 
-       /* Get interval values in 1/100th of a second */
-       get_itv_value(&record_hdr[curr], &record_hdr[!curr], &itv);
-
        /* Check time (2) */
        if (use_tm_end && (datecmp(rectime, &tm_end, cross_day) > 0)) {
                /* End time exceeded */
@@ -691,6 +688,9 @@ int generic_write_stats(int curr, int use_tm_start, int use_tm_end, int reset,
                return 0;
        }
 
+       /* Get interval values in 1/100th of a second */
+       get_itv_value(&record_hdr[curr], &record_hdr[!curr], &itv);
+
        dt = itv / 100;
        /* Correct rounding error for dt */
        if ((itv % 100) >= 50) {
diff --git a/sar.c b/sar.c
index 97be5db30249991f438e12ae54efdbc74d82f7d6..490016b3d6e036bf6b7dc919466cbe44d9745ae5 100644 (file)
--- a/sar.c
+++ b/sar.c
@@ -486,9 +486,6 @@ int write_stats(int curr, int read_from_file, long *cnt, int use_tm_start,
                cross_day = TRUE;
        }
 
-       /* Get interval value in 1/100th of a second */
-       get_itv_value(&record_hdr[curr], &record_hdr[!curr], &itv);
-
        /* Check time (2) */
        if (use_tm_end && (datecmp(&rectime, &tm_end, cross_day) > 0)) {
                /* End time exceeded */
@@ -496,6 +493,9 @@ int write_stats(int curr, int read_from_file, long *cnt, int use_tm_start,
                return 0;
        }
 
+       /* Get interval value in 1/100th of a second */
+       get_itv_value(&record_hdr[curr], &record_hdr[!curr], &itv);
+
        avg_count++;
 
        /* Test stdout */