Link to benchmark source from webpage
Is this something I could work on? Could you give me an example of a benchmark and the corresponding source code link it should refer to?
For sure! Here's a benchmark:
https://blog.anp.lol/lolbench-data/benchmarks/rayon-1-0-0-vec-collect-vec-i-filtered-with-collect.html
here's it's definition AFAICT:
https://github.com/anp/lolbench/blob/master/benches/rayon_1_0_0/src/vec_collect.rs#L258
Here are some places I would recommend looking in the code:
- the definition of the
wrap_libtest!macro which is where you'd be able to capture file and line information (possibly in the procedural macro too? although I'm not sure if proc macros can look at their callsite like that) - the definition of the
Benchmarkstruct which is serialized into the registry which is where I think you'd want to add the file/line/etc information so that it's persisted to source control and available for the website build. I imagine that at least locally you'll need to make any of those fields optional to start, so that you can successfully parse each existing registry entry before you're written your new field to each benchmark listing
I'm pretty sure that if you can make the necessary changes to those two locations and get everything else compiling again, it should be pretty straightforward to add to the website.
Okay, I started looking into this one a little bit yesterday. I think I'm having trouble figuring out just how to test this, especially since I'm not super adept with macros.
How/when is the registry.toml generated? What command do I need to run for that?
I think we can use line!() macro to get the callsite?
No worries, this is far from a normal Rust project setup. registry.toml is generated by a procedural macro that runs during the builds of all of the benchmarks, so if you run cargo check --all then you should regenerate it by forcing the benchmark runner's procedural macros to run.
I think that line! and file! should give you what you need to capture the callsite of the wrap_libtest! macro. We'll see!
I've made some progress, but I think I'm running into limitations of the proc_macro_hack crate, so I need some ideas on what to do. Hopefully I'm going about this the right way.
I've modified the defintion of lolbench_entrypoint_impl since this is how it gets turned into a Benchmark and ultimately gets serialized into registry.toml. This is what it looks like now:
proc_macro_expr_impl! {
/// Prepare and write to disk a single-function CLI entry-point for the passed benchmark fn.
pub fn lolbench_entrypoint_impl(bench_path: &str, source_path: &str, source_line: usize) -> String {
lolbench_entrypoint(bench_path, source_path, source_line).unwrap()
}
}
but this results in this error:
error: no rules expected the token `,`
--> extractor/src/lib.rs:18:53
|
18 | pub fn lolbench_entrypoint_impl(bench_path: &str, source_path: &str, source_line: usize) -> String {
| ^
error: aborting due to previous error
error: Could not compile `lolbench_extractor`.
...
So, it looks like you can't do multiple arguments through that macro, thoughts?