Skip to content

Commit d2aa83a

Browse files
author
Albin Ahlbäck
committed
fixup profiler for x86 linux
1 parent 11ca7b2 commit d2aa83a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/generic_files/profiler.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ prof_repeat(double * min, double * max, profile_target_t target, void * arg)
9595
# define PB (1ULL << 50)
9696
static inline void sprint_size(char * str, ulong bytes) {
9797
double num;
98-
char fmt[] = "%4.2f";
98+
char fmt[] = "%4.0f";
9999
if (bytes < kB)
100100
{
101101
sprintf(str, " %3" _WORD_FMT "u", bytes);
@@ -124,17 +124,18 @@ void fprint_memory_usage(FILE * fs)
124124
ulong virt = 0, virtpeak = 0, rss = 0, rsspeak = 0;
125125
char line[]
126126
= "virt/peak/rss/peak: 1234567 / 1234567 / 1234567 / 1234567\n";
127+
char tmp[128];
127128

128-
while (fgets(line, 128, file) != NULL)
129+
while (fgets(tmp, 128, file) != NULL)
129130
{
130-
if (strncmp(line, "VmSize:", 7) == 0)
131-
virt = strtoull(line + 8, NULL, 10);
132-
else if (strncmp(line, "VmPeak:", 7) == 0)
133-
virtpeak = strtoull(line + 8, NULL, 10);
134-
else if (strncmp(line, "VmRSS:", 6) == 0)
135-
rss = strtoull(line + 7, NULL, 10);
136-
else if (strncmp(line, "VmHWM:", 6) == 0)
137-
rsspeak = strtoull(line + 7, NULL, 10);
131+
if (strncmp(tmp, "VmSize:", 7) == 0)
132+
virt = strtoull(tmp + 8, NULL, 10);
133+
else if (strncmp(tmp, "VmPeak:", 7) == 0)
134+
virtpeak = strtoull(tmp + 8, NULL, 10);
135+
else if (strncmp(tmp, "VmRSS:", 6) == 0)
136+
rss = strtoull(tmp + 7, NULL, 10);
137+
else if (strncmp(tmp, "VmHWM:", 6) == 0)
138+
rsspeak = strtoull(tmp + 7, NULL, 10);
138139
}
139140
fclose(file);
140141

0 commit comments

Comments
 (0)