Benchmark("my-cool-benchmark") { measure in
// my setup code
measure { benchmark in // handing control to the benchmark framework. closure can be invoked multiple times
}
// my teardown code
}
Could do stuff like e.g.
Benchmark("my-cool-benchmark") { measure in
let pool = SomeConnectionPool()
await withTaskGroup { taskGroup in
taskGroup.addTask { await pool.run() }
measure { benchmark in // handing control to the benchmark framework. closure can be invoked multiple times
// do stuff with the pool
}
taskGroup.cancelAll()
}
}
Would be nice to streamline this a bit;
API suggestion:
it would be extremely cool, if we could return something from the setup hook that is then passed to the measure closure and the teardown hook
Like this:
this way we don’t need to capture values outside the closures - to have them handy in setup and teardown :slightly_smiling_face:
an alternative spelling could be this:
which would result in:
Could do stuff like e.g.