diff options
author | Aurelien Gateau <aurelien.gateau@canonical.com> | 2010-02-04 11:56:31 -0800 |
---|---|---|
committer | Aurelien Gateau <aurelien.gateau@canonical.com> | 2010-02-04 11:56:31 -0800 |
commit | 55a6f532fbc6a360158acaa52cd9071645beedf0 (patch) | |
tree | c8a40e08abdc82d08f8d346aba916364b8c5be37 /tools | |
parent | fae5fc031800b5be3ad41c8e6f32071e9abc5858 (diff) | |
download | libdbusmenu-55a6f532fbc6a360158acaa52cd9071645beedf0.tar.gz libdbusmenu-55a6f532fbc6a360158acaa52cd9071645beedf0.tar.bz2 libdbusmenu-55a6f532fbc6a360158acaa52cd9071645beedf0.zip |
- Output min and max in addition to average
- Use checkbox format
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/dbusmenubench.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tools/dbusmenubench.py b/tools/dbusmenubench.py index 7a50b2c..4b58da8 100755 --- a/tools/dbusmenubench.py +++ b/tools/dbusmenubench.py @@ -27,6 +27,7 @@ You should have received a copy of both the GNU Lesser General Public License version 3 and version 2.1 along with this program. If not, see <http://www.gnu.org/licenses/> """ +import itertools import time import sys from optparse import OptionParser @@ -38,6 +39,10 @@ DBUS_INTERFACE = "org.ayatana.dbusmenu" DBUS_SERVICE = "org.dbusmenu.test" DBUS_PATH = "/MenuBar" +PROBE_GET_LAYOUT = "GetLayout" +PROBE_GET_PROPERTIES = "GetProperties" +PROBE_GET_CHILDREN = "GetChildren" +PROBES = PROBE_GET_LAYOUT, PROBE_GET_PROPERTIES, PROBE_GET_CHILDREN class Chrono(object): def __init__(self): @@ -99,6 +104,12 @@ def run_test_sequence(menu, dump=False): return times +def create_timing_dict(): + return dict(zip(PROBES, itertools.repeat(0))) + +def print_probe(prefix, name, value, timestamp): + value = int(value * 1000000) + print "%(prefix)s.%(name)s:%(value)d@%(timestamp)d" % locals() def main(): parser = OptionParser(usage = "%prog [options]") @@ -118,14 +129,25 @@ def main(): run_test_sequence(menu, dump=True) return - cumulated_timings = dict() + cumulated_timings = create_timing_dict() + min_timings = create_timing_dict() + max_timings = create_timing_dict() for x in range(options.count): timings = run_test_sequence(menu) for name, timing in timings.items(): - cumulated_timings[name] = cumulated_timings.get(name, 0) + timing + cumulated_timings[name] += timing + if min_timings[name] == 0 or min_timings[name] > timing: + min_timings[name] = timing + if max_timings[name] < timing: + max_timings[name] = timing + timestamp = int(time.time()) for name, timing in cumulated_timings.items(): - print name, timing / options.count + print_probe("average", name, timing / options.count, timestamp) + for name, timing in min_timings.items(): + print_probe("min", name, timing, timestamp) + for name, timing in max_timings.items(): + print_probe("max", name, timing, timestamp) return 0 |