From d90c4088464b9ff81e36cb9c0213bb9ff0a91650 Mon Sep 17 00:00:00 2001 From: Mahmoud Hashemi Date: Sun, 25 Aug 2013 11:34:10 -0700 Subject: [PATCH] temporarily add the bencher why not --- boltons/_bench_omd.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 boltons/_bench_omd.py diff --git a/boltons/_bench_omd.py b/boltons/_bench_omd.py new file mode 100644 index 0000000..f43b1d5 --- /dev/null +++ b/boltons/_bench_omd.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +import sys +sys.path.append('/home/mahmoud/projects/lithoxyl/') + +import time +import lithoxyl +from lithoxyl import sinks, logger + +from dictutils import OMD +from werkzeug.datastructures import MultiDict, OrderedMultiDict as WOMD +from collections import OrderedDict as OD + +q_sink = lithoxyl.sinks.QuantileSink() +log = lithoxyl.logger.BaseLogger('bench_stats', sinks=[q_sink]) + +try: + profile +except NameError: + times = 100 + size = 1000 + redun = 10 +else: + times = 1 + size = 10000 + redun = 10 + +_rng = range(size / redun) * redun +_pairs = zip(_rng, _rng) + +for i in range(times): + with log.info('bench_omd') as r: + OMD(_pairs) + +#from pprint import pprint +#pprint(q_sink.get_histogram()) +best_msecs = q_sink.min * 1000 +median_msecs = q_sink.median * 1000 +print 'ran %d loops of %d items each, best time: %g ms, median time: %g ms' % (times, size, best_msecs, median_msecs)