[ray_client] add client microbenchmarks (#13007)

This commit is contained in:
Barak Michener
2020-12-21 12:17:44 -08:00
committed by GitHub
parent 5e2b850836
commit 43b9c7811e
8 changed files with 148 additions and 44 deletions
+6 -26
View File
@@ -2,17 +2,15 @@
import asyncio
import logging
import os
import time
from ray._private.ray_microbenchmark_helpers import timeit
from ray._private.ray_client_microbenchmark import (main as
client_microbenchmark_main)
import numpy as np
import multiprocessing
import ray
logger = logging.getLogger(__name__)
# Only run tests matching this filter pattern.
filter_pattern = os.environ.get("TESTS_TO_RUN", "")
@ray.remote(num_cpus=0)
class Actor:
@@ -71,27 +69,6 @@ def small_value_batch(n):
return 0
def timeit(name, fn, multiplier=1):
if filter_pattern not in name:
return
# warmup
start = time.time()
while time.time() - start < 1:
fn()
# real run
stats = []
for _ in range(4):
start = time.time()
count = 0
while time.time() - start < 2:
fn()
count += 1
end = time.time()
stats.append(multiplier * count / (end - start))
print(name, "per second", round(np.mean(stats), 2), "+-",
round(np.std(stats), 2))
def check_optimized_build():
if not ray._raylet.OPTIMIZED:
msg = ("WARNING: Unoptimized build! "
@@ -277,6 +254,9 @@ def main():
ray.get([async_actor_work.remote(a) for _ in range(m)])
timeit("n:n async-actor calls async", async_actor_multi, m * n)
ray.shutdown()
client_microbenchmark_main()
if __name__ == "__main__":