Skip to content
Snippets Groups Projects
Commit 751c4249 authored by Thomas Dillow's avatar Thomas Dillow
Browse files

Merge branch 'bench' into 'main'

can now change bench size stuff easily

See merge request awaghili/cse138-assignment-4-test-suite!9
parents d7a0e6a1 7f238543
No related branches found
No related tags found
No related merge requests found
...@@ -7,16 +7,17 @@ import time ...@@ -7,16 +7,17 @@ import time
import asyncio import asyncio
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
NUM_SHARDS = 16
NUM_KEYS = 10000
def benchmark_add_shard(conductor: ClusterConductor, dir, log: Logger): def benchmark_add_shard(conductor: ClusterConductor, dir, log: Logger):
with KVSTestFixture(conductor, dir, log, node_count=16) as fx: with KVSTestFixture(conductor, dir, log, node_count=NUM_SHARDS) as fx:
conductor.add_shard("shard1", conductor.get_nodes([0])) conductor.add_shard("shard1", conductor.get_nodes([0]))
fx.broadcast_view(conductor.get_shard_view()) fx.broadcast_view(conductor.get_shard_view())
log("putting 100 keys\n") log("putting 100 keys\n")
put_times = [] put_times = []
c = KVSMultiClient(fx.clients, "client", log, persist_metadata=False) for i in range(NUM_SHARDS):
for i in range(20000): c = KVSMultiClient(fx.clients, "client", log)
start_time = time.time() start_time = time.time()
r = c.put(0, f"key{i}", f"value{i}", timeout=10) r = c.put(0, f"key{i}", f"value{i}", timeout=10)
end_time = time.time() end_time = time.time()
...@@ -25,7 +26,7 @@ def benchmark_add_shard(conductor: ClusterConductor, dir, log: Logger): ...@@ -25,7 +26,7 @@ def benchmark_add_shard(conductor: ClusterConductor, dir, log: Logger):
log("Starting benchmark\n") log("Starting benchmark\n")
reshard_times = [] reshard_times = []
for shard in range(2, 17): for shard in range(2, NUM_SHARDS+1):
start_time = time.time() start_time = time.time()
log(f"adding shard{shard}\n") log(f"adding shard{shard}\n")
conductor.add_shard(f"shard{shard}", conductor.get_nodes([shard - 1])) conductor.add_shard(f"shard{shard}", conductor.get_nodes([shard - 1]))
...@@ -39,11 +40,11 @@ def benchmark_add_shard(conductor: ClusterConductor, dir, log: Logger): ...@@ -39,11 +40,11 @@ def benchmark_add_shard(conductor: ClusterConductor, dir, log: Logger):
log(f"shard count: {shard}, reshard time: {time_taken}") log(f"shard count: {shard}, reshard time: {time_taken}")
# Generate plot # Generate plot
plt.figure(figsize=(10, 6)) plt.figure(figsize=(NUM_SHARDS, 10))
plt.plot(range(2, 17), reshard_times, marker="o") plt.plot(range(2, NUM_SHARDS+1), reshard_times, marker='o')
plt.title("Reshard Times") plt.title('Reshard Times')
plt.xlabel("Number of Shards") plt.xlabel('Number of Shards')
plt.ylabel("Time (seconds)") plt.ylabel('Time (seconds)')
plt.grid(True) plt.grid(True)
plt.savefig(f"{dir}/reshard_times.png") plt.savefig(f"{dir}/reshard_times.png")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment