Unverified Commit 4e998f18 authored by Loïc Dachary's avatar Loïc Dachary
Browse files

do not randomize the seq/rand ratio

parent 1feebfbf
......@@ -520,16 +520,16 @@ class Reader(object):
return objects_count, bytes_read
def reader(args, image):
def reader(args, image, pattern):
reader = Reader(args, image)
if random.random() * 100 < args.rand_ratio:
if pattern == "rand":
(objects_count, bytes_read, too_long) = reader.read_rand()
too_long = None
(objects_count, bytes_read) = reader.read_seq()
return (image, objects_count, bytes_read, too_long)
return (image, objects_count, bytes_read, too_long, pattern)
class Bench(object):
......@@ -589,9 +589,12 @@ class Bench(object):
logging.warning("Bench.ro_loop: running")
self.readers = set()
pending_readers = ["seq"] * (self.args.ro_workers - self.args.rand_ratio) + [
] * self.args.rand_ratio
def create_reader():
return loop.run_in_executor(executor, reader, self.args, random.choice(self.images))
def create_reader(pattern):
return loop.run_in_executor(executor, reader, self.args, random.choice(self.images), pattern)
while not finished.is_set():
......@@ -599,13 +602,15 @@ class Bench(object):
await asyncio.sleep(1)
while len(self.readers) < self.args.ro_workers:
for pattern in pending_readers:
pending_readers = []
logging.debug(f"Bench.ro_loop: waiting on {len(self.readers)} readers")
done, self.readers = await asyncio.wait(self.readers, return_when=asyncio.FIRST_COMPLETED)
for task in done:
(image, objects, size, too_long) = task.result()
(image, objects, size, too_long, pattern) = task.result()
logging.debug(f"Bench.ro_loop: {image} {objects} objects, {size} bytes")
self.stats["object_read_count"] += objects
self.stats["bytes_read"] += size
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment