Skip to content

Commit 0d7bbb4

Browse files
Alexey Dobriyantorvalds
Alexey Dobriyan
authored andcommitted
scripts/bloat-o-meter: compile .NUMBER regex
Every often used regex is better be compiled in Python. Speedup is about ~9.8% (whee!) $ perf stat -r 16 taskset -c 15 ./scripts/bloat-o-meter ../vmlinux-000 ../obj/vmlinux >/dev/null 7.091202853 seconds time elapsed ( +- 0.15% ) +re.compile 6.397564973 seconds time elapsed ( +- 0.34% ) Link: http://lkml.kernel.org/r/20161119004417.GB1200@avx2 Signed-off-by: Alexey Dobriyan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3af06fd commit 0d7bbb4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: scripts/bloat-o-meter

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ if len(sys.argv) != 3:
1616
sys.stderr.write("usage: %s file1 file2\n" % sys.argv[0])
1717
sys.exit(-1)
1818

19+
re_NUMBER = re.compile(r'\.[0-9]+')
20+
1921
def getsizes(file):
2022
sym = {}
2123
with os.popen("nm --size-sort " + file) as f:
@@ -28,7 +30,7 @@ def getsizes(file):
2830
if name.startswith("compat_SyS_"): continue
2931
if name == "linux_banner": continue
3032
# statics and some other optimizations adds random .NUMBER
31-
name = re.sub(r'\.[0-9]+', '', name)
33+
name = re_NUMBER.sub('', name)
3234
sym[name] = sym.get(name, 0) + int(size, 16)
3335
return sym
3436

0 commit comments

Comments
 (0)