From 74a7a93bbe7ffda19823ab251209bb31979c465d Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Sun, 19 Aug 2012 14:11:10 +0200 Subject: pybootchartgui: make meminfo parsing faster Using a stricter regexp lets us filter early only the data we actually need. Doing meminfo parsing now takes ~50% less time. Signed-off-by: Armin Kuster --- scripts/pybootchartgui/pybootchartgui/parsing.py | 2 +- scripts/pybootchartgui/pybootchartgui/samples.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/pybootchartgui/pybootchartgui/parsing.py b/scripts/pybootchartgui/pybootchartgui/parsing.py index b7b2546ff1..6e139bfbd1 100644 --- a/scripts/pybootchartgui/pybootchartgui/parsing.py +++ b/scripts/pybootchartgui/pybootchartgui/parsing.py @@ -514,7 +514,7 @@ def _parse_proc_meminfo_log(file): The format of relevant lines should be: ^key: value( unit)? """ mem_stats = [] - meminfo_re = re.compile(r'([^ \t:]+):\s*(\d+).*') + meminfo_re = re.compile(r'(MemTotal|MemFree|Buffers|Cached|SwapTotal|SwapFree):\s*(\d+).*') for time, lines in _parse_timed_blocks(file): sample = MemSample(time) diff --git a/scripts/pybootchartgui/pybootchartgui/samples.py b/scripts/pybootchartgui/pybootchartgui/samples.py index 9fc309b3ab..89798682d5 100644 --- a/scripts/pybootchartgui/pybootchartgui/samples.py +++ b/scripts/pybootchartgui/pybootchartgui/samples.py @@ -45,8 +45,7 @@ class MemSample: self.records = {} def add_value(self, name, value): - if name in MemSample.used_values: - self.records[name] = value + self.records[name] = value def valid(self): keys = self.records.keys() -- cgit 1.2.3-korg