Re: [PATCH] rearrange struct value to save memory

Tom Tromey
2014-01-13T20:02:52Z

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> It does save some memory shown by the result of 'make perf-check' on
Yao> an amd64-linux box. I don't see any time performance regression
Yao> in the test. It is indeed a good improvement!

Yao> Original Patched
Yao> backtrace vmsize 2 55108 54316
Yao> backtrace vmsize 4 55108 52432
Yao> backtrace vmsize 8 53124 51512
[...]

I tried perf-check out on another branch today. I didn't see a canned
way to summarize the results, so I wrote the appended. You'll need a
newish version of prettytable if you don't want the colorizing to mess
up the table.

This is still pretty dumb... I didn't try to deal with graphing or
anything cool like that.

Tom

#!/usr/bin/python

from termcolor import colored
import re
import fileinput
import prettytable

rx = re.compile('^(.*)\s([0-9.]+)$')

# Allow 5% noise.
NOISE = 0.05

results = {}

for line in fileinput.input():
m = rx.match(line)
if m:
name = m.group(1)
value = float(m.group(2))

if name not in results:
results[name] = []
results[name].append(value)

keys = results.keys()
keys.sort()

tab = prettytable.PrettyTable()
for name in keys:
vals = results[name]
newvals = [name, str(vals[0])]
for i in range(1, len(vals)):
perc = abs((vals[i] - vals[i - 1]) / vals[i - 1])
nv = str(vals[i])
if perc > NOISE:
if vals[i] > vals[i - 1]:
nv = colored(nv, 'red')
elif vals[i] < vals[i - 1]:
nv = colored(nv, 'green')
newvals.append(nv)

tab.add_row(newvals)

print tab