2 # -*- coding: utf-8; mode: python; -*-
4 # GStreamer Debug Viewer - View and analyze GStreamer debug log files
6 # Copyright (C) 2007 René Stadler <mail@renestadler.de>
8 # This program is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by the Free
10 # Software Foundation; either version 3 of the License, or (at your option)
13 # This program is distributed in the hope that it will be useful, but WITHOUT
14 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 # You should have received a copy of the GNU General Public License along with
19 # this program. If not, see <http://www.gnu.org/licenses/>.
21 """GStreamer Debug Viewer performance test program."""
31 from gi.repository import GObject
33 from .. import Common, Data, GUI
36 class TestParsingPerformance (object):
38 def __init__(self, filename):
40 self.main_loop = GObject.MainLoop()
41 self.log_file = Data.LogFile(filename, Common.Data.DefaultDispatcher())
42 self.log_file.consumers.append(self)
46 self.log_file.start_loading()
48 def handle_load_started(self):
50 self.start_time = time.time()
52 def handle_load_finished(self):
54 diff = time.time() - self.start_time
55 print("line cache built in %0.1f ms" % (diff * 1000.,))
57 start_time = time.time()
58 model = GUI.LazyLogModel(self.log_file)
61 diff = time.time() - start_time
62 print("model iterated in %0.1f ms" % (diff * 1000.,))
63 print("overall time spent: %0.1f s" % (time.time() - self.start_time,))
66 rusage = resource.getrusage(resource.RUSAGE_SELF)
67 print("time spent in user mode: %.2f s" % (rusage.ru_utime,))
68 print("time spent in system mode: %.2f s" % (rusage.ru_stime,))
74 test = TestParsingPerformance(sys.argv[1])
78 if __name__ == "__main__":