Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for generic benchmark groups #6

Open
nvzqz opened this issue Oct 6, 2023 · 0 comments
Open

Support for generic benchmark groups #6

nvzqz opened this issue Oct 6, 2023 · 0 comments

Comments

@nvzqz
Copy link
Owner

nvzqz commented Oct 6, 2023

Generic types and consts options should be providable through #[divan::bench_group]:

#[divan::bench_group(types = [Vec<i32>, HashSet<i32>, BTreeSet<i32>, LinkedList<i32>])]
mod group {
    #[divan::bench]
    fn bench1<T>() {}

    #[divan::bench]
    fn bench2<T>() {}
}

This would be equivalent to:

#[divan::bench_group]
mod group {
    #[divan::bench(types = [Vec<i32>, HashSet<i32>, BTreeSet<i32>, LinkedList<i32>])]
    fn bench1<T>() {}

    #[divan::bench(types = [Vec<i32>, HashSet<i32>, BTreeSet<i32>, LinkedList<i32>])]
    fn bench2<T>() {}
}

This can be achieved by having #[divan::bench_group] rewrite each #[divan::bench] to include the appropriate types or consts option. If a benchmark already has its own types or consts option, we can skip it. To automatically make types visible within the group without importing from the super scope, we could create our own type aliases in the parent to then be used via super:: on rewrite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant