]> arthur.barton.de Git - netdata.git/commitdiff
minor optimizations: eliminated an snprintf and lowered the stack allocated buffers
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 15 Sep 2016 21:03:30 +0000 (00:03 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 15 Sep 2016 21:03:30 +0000 (00:03 +0300)
src/proc_interrupts.c
src/proc_softirqs.c

index 53c9344e45ec2d18df3dd49634ed031d1b962e75..be3792f275db36f2c3c2339fd2288ce5b510e72f 100644 (file)
@@ -143,15 +143,14 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
         int c;
 
         for(c = 0; c < cpus ; c++) {
-            char id[256+1];
-            snprintfz(id, 256, "cpu%d_interrupts", c);
+            char id[50+1];
+            snprintfz(id, 50, "cpu%d_interrupts", c);
 
             st = rrdset_find_bytype("cpu", id);
             if(!st) {
-                char name[256+1], title[256+1];
-                snprintfz(name, 256, "cpu%d_interrupts", c);
-                snprintfz(title, 256, "CPU%d Interrupts", c);
-                st = rrdset_create("cpu", id, name, "interrupts", "cpu.interrupts", title, "interrupts/s", 1100 + c, update_every, RRDSET_TYPE_STACKED);
+                char title[100+1];
+                snprintfz(title, 100, "CPU%d Interrupts", c);
+                st = rrdset_create("cpu", id, NULL, "interrupts", "cpu.interrupts", title, "interrupts/s", 1100 + c, update_every, RRDSET_TYPE_STACKED);
 
                 for(l = 0; l < lines ;l++) {
                     struct interrupt *irr = irrindex(irrs, l, cpus);
index a5165040acecc9da79ba349c001c7a2729800bbc..701153e66d316caa3d83bb0be494387e5059e53a 100644 (file)
@@ -134,8 +134,8 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
         int c;
 
         for(c = 0; c < cpus ; c++) {
-            char id[256+1];
-            snprintfz(id, 256, "cpu%d_softirqs", c);
+            char id[50+1];
+            snprintfz(id, 50, "cpu%d_softirqs", c);
 
             st = rrdset_find_bytype("cpu", id);
             if(!st) {
@@ -148,10 +148,9 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
                 }
                 if(core_sum == 0) continue; // try next core
 
-                char name[256+1], title[256+1];
-                snprintfz(name, 256, "cpu%d_softirqs", c);
-                snprintfz(title, 256, "CPU%d softirqs", c);
-                st = rrdset_create("cpu", id, name, "softirqs", "cpu.softirqs", title, "softirqs/s", 3000 + c, update_every, RRDSET_TYPE_STACKED);
+                char title[100+1];
+                snprintfz(title, 100, "CPU%d softirqs", c);
+                st = rrdset_create("cpu", id, NULL, "softirqs", "cpu.softirqs", title, "softirqs/s", 3000 + c, update_every, RRDSET_TYPE_STACKED);
 
                 for(l = 0; l < lines ;l++) {
                     struct interrupt *irr = irrindex(irrs, l, cpus);