minor optimizations: eliminated an snprintf and lowered the stack allocated buffers
Costa Tsaousis (ktsaou) committed
Sep 16, 2016 at 00:03 UTC
5029908dbba56478a542fe93bd4b057e16030105
2 files changed
+10
-12
src/proc_interrupts.c
+5
-6
@@ -143,15 +143,14 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
143
int c;
144
145
for(c = 0; c < cpus ; c++) {
146
- char id[256+1];
147
- snprintfz(id, 256, "cpu%d_interrupts", c);
146
+ char id[50+1];
147
+ snprintfz(id, 50, "cpu%d_interrupts", c);
148
149
st = rrdset_find_bytype("cpu", id);
150
if(!st) {
151
- char name[256+1], title[256+1];
152
- snprintfz(name, 256, "cpu%d_interrupts", c);
153
- snprintfz(title, 256, "CPU%d Interrupts", c);
154
- st = rrdset_create("cpu", id, name, "interrupts", "cpu.interrupts", title, "interrupts/s", 1100 + c, update_every, RRDSET_TYPE_STACKED);
151
+ char title[100+1];
152
+ snprintfz(title, 100, "CPU%d Interrupts", c);
153
+ st = rrdset_create("cpu", id, NULL, "interrupts", "cpu.interrupts", title, "interrupts/s", 1100 + c, update_every, RRDSET_TYPE_STACKED);
154
155
for(l = 0; l < lines ;l++) {
156
struct interrupt *irr = irrindex(irrs, l, cpus);
src/proc_softirqs.c
+5
-6
@@ -134,8 +134,8 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
134
int c;
135
136
for(c = 0; c < cpus ; c++) {
137
- char id[256+1];
138
- snprintfz(id, 256, "cpu%d_softirqs", c);
137
+ char id[50+1];
138
+ snprintfz(id, 50, "cpu%d_softirqs", c);
139
140
st = rrdset_find_bytype("cpu", id);
141
if(!st) {
@@ -148,10 +148,9 @@ int do_proc_softirqs(int update_every, unsigned long long dt) {
148
}
149
if(core_sum == 0) continue; // try next core
150
151
- char name[256+1], title[256+1];
152
- snprintfz(name, 256, "cpu%d_softirqs", c);
153
- snprintfz(title, 256, "CPU%d softirqs", c);
154
- st = rrdset_create("cpu", id, name, "softirqs", "cpu.softirqs", title, "softirqs/s", 3000 + c, update_every, RRDSET_TYPE_STACKED);
151
+ char title[100+1];
152
+ snprintfz(title, 100, "CPU%d softirqs", c);
153
+ st = rrdset_create("cpu", id, NULL, "softirqs", "cpu.softirqs", title, "softirqs/s", 3000 + c, update_every, RRDSET_TYPE_STACKED);
154
155
for(l = 0; l < lines ;l++) {
156
struct interrupt *irr = irrindex(irrs, l, cpus);