-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
49 lines (38 loc) · 1.43 KB
/
plot.py
File metadata and controls
49 lines (38 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import json
import matplotlib.pyplot as plt
import math
import numpy as np
# Read the results from the file
with open('results.jsonl', 'r') as f:
results = [json.loads(line) for line in f.readlines()]
# Organize data by filter size
filter_size_to_ratios = {}
for result in results:
filter_size = result['args']['filter_size']
log2_size = int(math.log2(filter_size))
unsorted_ms = result['unsorted']['milliseconds']
sorted_ms = result['sorted']['milliseconds']
ratio = unsorted_ms / sorted_ms
if log2_size not in filter_size_to_ratios:
filter_size_to_ratios[log2_size] = []
filter_size_to_ratios[log2_size].append(ratio)
# Calculate mean and standard deviation for each filter size
x_values = []
y_values = []
y_errors = []
for log2_size, ratios in sorted(filter_size_to_ratios.items()):
x_values.append(log2_size)
y_values.append(np.mean(ratios))
y_errors.append(np.std(ratios))
# Create the plot
plt.figure(figsize=(10, 6))
plt.errorbar(x_values, y_values, yerr=y_errors, fmt='o-', linewidth=2, markersize=8, capsize=5)
plt.axhline(y=1.0, color='r', linestyle='--', alpha=0.7) # Reference line at ratio=1
# Add labels and title with increased font sizes
plt.xlabel('Bloom Filter Size (log2 bits)', fontsize=14)
plt.ylabel('Time Ratio (Unsorted/Sorted)', fontsize=14)
plt.grid(True, alpha=0.3)
# Format the y-axis to show ratio properly
plt.tight_layout()
# Save the plot
plt.savefig('speed_ratio.pdf')