Remove code duplications in benchmarks#5209
Remove code duplications in benchmarks#5209ThierryBerger wants to merge 11 commits intobevyengine:mainfrom
Conversation
- made macro to generate storage benches rather than duplicate - new test for detecting only a few changes
There was a problem hiding this comment.
I removed a code duplication as an example of what's possible, The future commits should be very similar so feedbacks are already appreciated 👍.
I recommend to check this latest commit 31733cc rather than the whole diff because this Pull Request is built on top of another branch.
Older commit d68486f is also new, but builds on what is or will be agreed from parent branch #4972.
| @@ -1,3 +1,5 @@ | |||
| use crate::generic_bench; | |||
There was a problem hiding this comment.
Changes in this file use the same logic of #4972
| @@ -0,0 +1,212 @@ | |||
| use crate::generic_bench; | |||
There was a problem hiding this comment.
No changes in this file because part of #4972
| type BenchGroup<'a> = BenchmarkGroup<'a, criterion::measurement::WallTime>; | ||
|
|
||
| pub fn generic_bench<P: Copy>( | ||
| bench_group: &mut BenchmarkGroup<criterion::measurement::WallTime>, | ||
| mut benches: Vec<Box<dyn FnMut(&mut BenchGroup, P)>>, | ||
| bench_parameters: P, | ||
| ) { | ||
| for b in &mut benches { | ||
| b(bench_group, bench_parameters); | ||
| } | ||
| } |
There was a problem hiding this comment.
From #4972.
Few questions:
- Should this approach be translated into
Benchmarkstructs ? - Or
Benchmarkstructs converted to this approach ? - Or leave as-is for now 🤷
|
Take a look at #3505 too :) I stumbled across it the other day. If you want to incorporate those changes please do so and credit the author. |
|
Backlog cleanup: closing due to inactivity, with a nod to existing tracking issue #5161. |
Objective
Fixes #5161
Built ont top of #4972
Solution