Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1525738

[PATCH 2/2] scripts/bloat-o-meter: compile .NUMBER regex

From Alexey Dobriyan <adobriyan@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 2/2] scripts/bloat-o-meter: compile .NUMBER regex
Date 2016-11-18 23:50 +0100
Message-ID <sF08N-4RY-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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% )

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 scripts/bloat-o-meter |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
@@ -16,6 +16,8 @@ if len(sys.argv) != 3:
     sys.stderr.write("usage: %s file1 file2\n" % sys.argv[0])
     sys.exit(-1)
 
+re_NUMBER = re.compile(r'\.[0-9]+')
+
 def getsizes(file):
     sym = {}
     with os.popen("nm --size-sort " + file) as f:
@@ -28,7 +30,7 @@ def getsizes(file):
                 if name.startswith("compat_SyS_"): continue
                 if name == "linux_banner": continue
                 # statics and some other optimizations adds random .NUMBER
-                name = re.sub(r'\.[0-9]+', '', name)
+                name = re_NUMBER.sub('', name)
                 sym[name] = sym.get(name, 0) + int(size, 16)
     return sym
 

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 2/2] scripts/bloat-o-meter: compile .NUMBER regex Alexey Dobriyan <adobriyan@gmail.com> - 2016-11-18 23:50 +0100

csiph-web