]> granicus.if.org Git - sysstat/commitdiff
sar: "--iface=" option: Small optimization
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 13 May 2018 13:56:39 +0000 (15:56 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 13 May 2018 13:56:39 +0000 (15:56 +0200)
Don't look for previous statistics sample if current network device will
not be displayed.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
pr_stats.c

index a0f106d77f789ec72724f346a63ed9c0af6834b5..8499d351ab2721330daf163fa5a9a6a1cbd8181e 100644 (file)
@@ -1134,6 +1134,14 @@ __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
        for (i = 0; i < a->nr[curr]; i++) {
                sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
 
+               if (dlist_idx) {
+                       /* A list of devices has been entered on the command line */
+                       if (!search_sa_dlist(st_dev_list, dlist_idx, sndc->interface,
+                                            A_NET_DEV))
+                               /* Device not found */
+                               continue;
+               }
+
                if (!WANT_SINCE_BOOT(flags)) {
                        j = check_net_dev_reg(a, curr, prev, i);
                }
@@ -1154,14 +1162,6 @@ __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
                if (DISPLAY_ZERO_OMIT(flags) && !memcmp(sndp, sndc, STATS_NET_DEV_SIZE2CMP))
                        continue;
 
-               if (dlist_idx) {
-                       /* A list of devices has been entered on the command line */
-                       if (!search_sa_dlist(st_dev_list, dlist_idx, sndc->interface,
-                                            A_NET_DEV))
-                               /* Device not found */
-                               continue;
-               }
-
                printf("%-11s", timestamp[curr]);
 
                if (!DISPLAY_HUMAN_READ(flags)) {
@@ -1215,6 +1215,14 @@ __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
        for (i = 0; i < a->nr[curr]; i++) {
                snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
 
+               if (dlist_idx) {
+                       /* A list of devices has been entered on the command line */
+                       if (!search_sa_dlist(st_dev_list, dlist_idx, snedc->interface,
+                                            A_NET_DEV))
+                               /* Device not found */
+                               continue;
+               }
+
                if (!WANT_SINCE_BOOT(flags)) {
                        j = check_net_edev_reg(a, curr, prev, i);
                }
@@ -1235,14 +1243,6 @@ __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
                if (DISPLAY_ZERO_OMIT(flags) && !memcmp(snedp, snedc, STATS_NET_EDEV_SIZE2CMP))
                        continue;
 
-               if (dlist_idx) {
-                       /* A list of devices has been entered on the command line */
-                       if (!search_sa_dlist(st_dev_list, dlist_idx, snedc->interface,
-                                            A_NET_DEV))
-                               /* Device not found */
-                               continue;
-               }
-
                printf("%-11s", timestamp[curr]);
 
                if (!DISPLAY_HUMAN_READ(flags)) {