From c7f80a0c4b82d9977add2d5bbda355247cdf6ffe Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Wed, 27 Feb 2013 08:22:39 +0100 Subject: [PATCH] mpc: optimize HZ retrieval As Brian De Wolf noted: hz only really needs to be calculated once, so this line could be moved up out of the loop, resulting in a likely unnoticeable performance increase. :) --- tools/munin-plugins-busybox/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/munin-plugins-busybox/cpu.c b/tools/munin-plugins-busybox/cpu.c index 0cfa1d45..f8e53e6c 100644 --- a/tools/munin-plugins-busybox/cpu.c +++ b/tools/munin-plugins-busybox/cpu.c @@ -136,8 +136,8 @@ int cpu(int argc, char **argv) { } if(!(f=fopen(PROC_STAT, "r"))) return fail("cannot open " PROC_STAT); + hz = getenvint("HZ", 100); while(fgets(buff, 256, f)) { - hz = getenvint("HZ", 100); if(!strncmp(buff, "cpu ", 4)) { fclose(f); if(!(s = strtok(buff+4, " \t")))