Skip to content

Commit 3e4ac37

Browse files
committed
update
1 parent ead33f6 commit 3e4ac37

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

examples/main.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,26 +219,27 @@ def run_benchmark(
219219
) -> Dict[str, float]:
220220
"""Run benchmark for specific parameters."""
221221
recall = 0.0
222-
elapsed = 0.0
222+
max_qps = 0.0
223+
max_bandwidth = 0.0
223224
for run in range(runs):
224225
start_time = time()
225226
results, distances = glass_index.search(queries, topk, ef, concurrency)
226-
elapsed += time() - start_time
227+
elapsed = time() - start_time
228+
qps = len(queries) / elapsed
229+
max_qps = max(max_qps, qps)
230+
stats = glass_index.get_stats()
231+
bandwidth = stats["mem_read_bytes"] / 1024 / 1024 / 1024 / elapsed
232+
max_bandwidth = max(max_bandwidth, bandwidth)
233+
227234
if run == 0:
228235
recall = calculate_recall(results, ground_truth)
229236

230-
qps = runs * len(queries) / elapsed
231-
232-
stats = glass_index.get_stats()
233-
234-
bandwidth = runs * stats["mem_read_bytes"] / 1024 / 1024 / 1024 / elapsed
235-
236237
return {
237238
"recall": recall,
238-
"qps": qps,
239+
"qps": max_qps,
239240
"p99_latency_ms": stats["p99_latency_ms"],
240241
"avg_dist_comps": stats["avg_dist_comps"],
241-
"mem_bandwidth": bandwidth,
242+
"mem_bandwidth": max_bandwidth,
242243
}
243244

244245

glass/neighbor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct Bitset {
7878
bool get(int i) const { return (data[i / block_size] >> (i & (block_size - 1))) & 1; }
7979
};
8080

81-
template <typename Block = uint32_t>
81+
template <typename Block = uint64_t>
8282
struct TwoLevelBitset {
8383
constexpr static int block_size = sizeof(Block) * 8;
8484
int32_t nb = 0;

0 commit comments

Comments
 (0)