Skip to content

Commit 83f071d

Browse files
committed
Simplify bench
1 parent 80f53d6 commit 83f071d

1 file changed

Lines changed: 17 additions & 75 deletions

File tree

benches/benchmarks.rs

Lines changed: 17 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -88,89 +88,31 @@ fn create_test_events() -> Vec<InputEvent> {
8888
fn benchmark_apply_anxious_scroll(c: &mut Criterion) {
8989
let mut group = c.benchmark_group("apply_anxious_scroll");
9090

91-
// Test different velocity scenarios
92-
let scenarios = vec![
93-
("slow_scroll", 1.0, Duration::from_millis(100)), // 10 units/sec
94-
("medium_scroll", 5.0, Duration::from_millis(50)), // 100 units/sec
95-
("fast_scroll", 15.0, Duration::from_millis(10)), // 1500 units/sec
96-
("very_fast_scroll", 50.0, Duration::from_millis(5)), // 10000 units/sec
97-
];
98-
99-
for (name, value, elapsed) in scenarios {
100-
group.bench_with_input(
101-
BenchmarkId::new("velocity_scenarios", name),
102-
&(value, elapsed),
103-
|b, (value, elapsed)| {
104-
let params = AnxiousParams::default();
105-
// Use a fixed timestamp to avoid SystemTime overflow issues
106-
let base_time = UNIX_EPOCH + Duration::from_secs(1000000000); // Far in the future
107-
let mut state = create_anxious_state_with_time(base_time);
108-
let timestamp = base_time + *elapsed; // Pre-compute timestamp outside hot path
109-
110-
b.iter(|| {
111-
// Only measure the hot path: apply_anxious_scroll call
112-
black_box(apply_anxious_scroll(
113-
black_box(*value),
114-
black_box(timestamp),
115-
black_box(&params),
116-
black_box(&mut state),
117-
))
118-
})
119-
},
120-
);
121-
}
91+
// Simple benchmark of the core function - velocity doesn't affect performance
92+
group.bench_function("core_function", |b| {
93+
let params = AnxiousParams::default();
94+
let base_time = UNIX_EPOCH + Duration::from_secs(1000000000);
95+
let mut state = create_anxious_state_with_time(base_time);
96+
let timestamp = base_time + Duration::from_millis(10);
12297

123-
// Test different parameter configurations
124-
let param_configs = vec![
125-
("default", AnxiousParams::default()),
126-
(
127-
"high_sensitivity",
128-
AnxiousParams {
129-
base_sens: 1.0,
130-
max_sens: 30.0,
131-
ramp_up_rate: 0.5,
132-
},
133-
),
134-
(
135-
"low_sensitivity",
136-
AnxiousParams {
137-
base_sens: 0.5,
138-
max_sens: 5.0,
139-
ramp_up_rate: 0.1,
140-
},
141-
),
142-
];
143-
144-
for (name, params) in param_configs {
145-
group.bench_with_input(
146-
BenchmarkId::new("parameter_configs", name),
147-
&params,
148-
|b, params| {
149-
let base_time = UNIX_EPOCH + Duration::from_secs(1000000000);
150-
let mut state = create_anxious_state_with_time(base_time);
151-
let timestamp = base_time + Duration::from_millis(10); // Pre-compute timestamp outside hot path
152-
153-
b.iter(|| {
154-
// Only measure the hot path: apply_anxious_scroll call
155-
black_box(apply_anxious_scroll(
156-
black_box(10.0),
157-
black_box(timestamp),
158-
black_box(params),
159-
black_box(&mut state),
160-
))
161-
})
162-
},
163-
);
164-
}
98+
b.iter(|| {
99+
black_box(apply_anxious_scroll(
100+
black_box(120.0),
101+
black_box(timestamp),
102+
black_box(&params),
103+
black_box(&mut state),
104+
))
105+
})
106+
});
165107

166108
group.finish();
167109
}
168110

169111
fn benchmark_event_processing(c: &mut Criterion) {
170112
let mut group = c.benchmark_group("event_processing");
171113

172-
// Test different batch sizes - simplified to avoid timestamp issues
173-
let batch_sizes = vec![1, 5, 10, 20, 50];
114+
// Test different batch sizes
115+
let batch_sizes = vec![1, 5, 10, 20];
174116

175117
for size in batch_sizes {
176118
group.bench_with_input(BenchmarkId::new("batch_size", size), &size, |b, &size| {

0 commit comments

Comments
 (0)