Merge "benchmark: use processes rather than threads"
This commit is contained in:
commit
d93d5cf92f
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue