2018-05-22 16:20:39 -07:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import division
|
|
|
|
from __future__ import print_function
|
|
|
|
|
2018-05-31 00:06:17 -07:00
|
|
|
import ray
|
|
|
|
|
|
|
|
|
|
|
|
def setup():
|
2018-06-05 15:55:35 -07:00
|
|
|
if not hasattr(setup, "is_initialized"):
|
|
|
|
ray.init(num_workers=4, num_cpus=4)
|
|
|
|
setup.is_initialized = True
|
2018-05-31 00:06:17 -07:00
|
|
|
|
2018-05-22 16:20:39 -07:00
|
|
|
|
2018-08-10 17:52:36 -07:00
|
|
|
@ray.remote
|
|
|
|
def trivial_function():
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
2018-05-22 16:20:39 -07:00
|
|
|
class TimeSuite(object):
|
|
|
|
"""An example benchmark."""
|
|
|
|
|
|
|
|
def setup(self):
|
|
|
|
self.d = {}
|
|
|
|
for x in range(500):
|
|
|
|
self.d[x] = None
|
|
|
|
|
|
|
|
def time_keys(self):
|
|
|
|
for key in self.d.keys():
|
|
|
|
pass
|
|
|
|
|
|
|
|
def time_range(self):
|
|
|
|
d = self.d
|
|
|
|
for key in range(500):
|
|
|
|
d[key]
|
|
|
|
|
|
|
|
|
|
|
|
class MemSuite(object):
|
|
|
|
def mem_list(self):
|
|
|
|
return [0] * 256
|
2018-05-31 00:06:17 -07:00
|
|
|
|
|
|
|
|
|
|
|
class MicroBenchmarkSuite(object):
|
|
|
|
def time_submit(self):
|
2018-08-10 17:52:36 -07:00
|
|
|
trivial_function.remote()
|
2018-05-31 00:06:17 -07:00
|
|
|
|
|
|
|
def time_submit_and_get(self):
|
2018-08-10 17:52:36 -07:00
|
|
|
x = trivial_function.remote()
|
2018-05-31 00:06:17 -07:00
|
|
|
ray.get(x)
|
|
|
|
|
|
|
|
def time_put(self):
|
|
|
|
ray.put(1)
|