MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / profile_workload

Function profile_workload

rust/src/bin/function_profiler.rs:61–173  ·  view source on GitHub ↗
(workload: Vec<Operation>)

Source from the content-addressed store, hash-verified

59}
60
61fn profile_workload(workload: Vec<Operation>) {
62 let mut tree = BPlusTreeMap::new(16).unwrap();
63 let mut profiles: HashMap<String, ProfileData> = HashMap::new();
64
65 // Pre-populate tree
66 for i in 0..50_000 {
67 tree.insert(i, format!("value_{}", i));
68 }
69
70 println!("Executing {} operations...", workload.len());
71 let total_start = Instant::now();
72
73 for op in workload {
74 match op {
75 Operation::Delete(key) => {
76 let start = Instant::now();
77 let result = tree.remove(&key);
78 let duration = start.elapsed();
79
80 profiles
81 .entry("remove".to_string())
82 .or_insert_with(ProfileData::new)
83 .record(duration);
84
85 // Track successful vs failed deletes
86 if result.is_some() {
87 profiles
88 .entry("successful_delete".to_string())
89 .or_insert_with(ProfileData::new)
90 .record(duration);
91 } else {
92 profiles
93 .entry("failed_delete".to_string())
94 .or_insert_with(ProfileData::new)
95 .record(duration);
96 }
97 }
98 Operation::Insert(key, value) => {
99 let start = Instant::now();
100 tree.insert(key, value);
101 let duration = start.elapsed();
102
103 profiles
104 .entry("insert".to_string())
105 .or_insert_with(ProfileData::new)
106 .record(duration);
107 }
108 Operation::Lookup(key) => {
109 let start = Instant::now();
110 tree.get(&key);
111 let duration = start.elapsed();
112
113 profiles
114 .entry("lookup".to_string())
115 .or_insert_with(ProfileData::new)
116 .record(duration);
117 }
118 }

Callers 1

profile_delete_scenariosFunction · 0.85

Calls 4

recordMethod · 0.80
insertMethod · 0.45
removeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected