Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[asv] Add benchmark for ray.wait #2625

Merged
merged 2 commits into from
Aug 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions python/benchmarks/benchmark_wait.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import time

import ray


def setup(*args):
if not hasattr(setup, "is_initialized"):
ray.init(num_workers=4, num_cpus=4)
setup.is_initialized = True


@ray.remote
def sleep(x):
time.sleep(x)


class WaitSuite(object):
timeout = 10
timer = time.time

def time_wait_task(self):
ray.wait([sleep.remote(0.1)])

def time_wait_many_tasks(self, num_returns):
tasks = [sleep.remote(i / 5) for i in range(4)]
ray.wait(tasks, num_returns=num_returns)

time_wait_many_tasks.params = list(range(1, 4))
time_wait_many_tasks.param_names = ["num_returns"]

def time_wait_timeout(self, timeout):
ray.wait([sleep.remote(0.5)], timeout=timeout)

time_wait_timeout.params = [200, 800]
time_wait_timeout.param_names = ["timeout_ms"]
10 changes: 7 additions & 3 deletions python/benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import print_function

import ray
import ray.test.test_functions as test_functions


def setup():
Expand All @@ -12,6 +11,11 @@ def setup():
setup.is_initialized = True


@ray.remote
def trivial_function():
return 1


class TimeSuite(object):
"""An example benchmark."""

Expand All @@ -37,10 +41,10 @@ def mem_list(self):

class MicroBenchmarkSuite(object):
def time_submit(self):
test_functions.empty_function.remote()
trivial_function.remote()

def time_submit_and_get(self):
x = test_functions.trivial_function.remote()
x = trivial_function.remote()
ray.get(x)

def time_put(self):
Expand Down