google / benchmark

A microbenchmark support library
Apache License 2.0
8.6k stars 1.57k forks source link

regex match specific benchmark names #1695

Closed ahmednofal closed 8 months ago

ahmednofal commented 8 months ago

Thank you for your work on this great project,

I am trying to use the --benchmark_filter=<regex> option but no matter which regex I use, I cant make it to match exactly the specific benchmark cases I want. I use it this way: --benchmark_filter=(BenchmarkName/1/1/1|Benchmark/2/1/1) but this also matches for instance all benchmark cases that has BenchmarkName/1/1/1 in the beginning so it matches BenchmarkName/1/1/16 and BenchmarkName/1/1/128 as well.

TL;DR I need to run only specific benchmark cases that are named name1 name2 name3 but name1 matches also name16 and name128 as well. Thank you

ahmednofal commented 8 months ago

I found the solution, probably could not figure it out because it is not clear which regex flavor google benchmark uses. Solution : put ^ at the beginning and $ at the end of the benchmark case name. Example: --benchmark_filter=^BenchmarkName/1/1/1$