Merge "benchmark: use processes rather than threads"

This commit is contained in:
Jenkins 2015-10-09 11:10:01 +00:00 committed by Gerrit Code Review
commit d93d5cf92f
1 changed files with 11 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import functools
import logging
import random
import time
import types
from cliff import show
import futurist
@ -28,6 +29,15 @@ from gnocchiclient.v1 import metric_cli
LOG = logging.getLogger(__name__)
def _pickle_method(m):
if m.im_self is None:
return getattr, (m.im_class, m.im_func.func_name)
else:
return getattr, (m.im_self, m.im_func.func_name)
six.moves.copyreg.pickle(types.MethodType, _pickle_method)
def grouper(iterable, n, fillvalue=None):
"Collect data into fixed-length chunks or blocks"
# grouper('ABCDEFG', 3, 'x') --> ABC DEF
@ -49,7 +59,7 @@ def _positive_non_zero_int(argument_value):
return value
class BenchmarkPool(futurist.ThreadPoolExecutor):
class BenchmarkPool(futurist.ProcessPoolExecutor):
def submit_job(self, times, fn, *args, **kwargs):
self.sw = timeutils.StopWatch()
self.sw.start()