Closed valeriyvan closed 1 week ago
Thanks for the report - @lehtihet do you think you could help out with this one please?
There are three problems in the sample benchmark code from the readme which is causing this build failure to occur:
1 and 2. the functions defaultCounter()
and dummyCounter(_ count: Int)
are created in Benchmarks/Benchmarks/Basic/BenchmarkRunner+Basic.swift
and are not accessible by simply importing the benchmark tool.
maxDuration: .seconds(10)) { benchmark in
should be maxDuration: .seconds(10))) { benchmark in
As a temporary workaround to get the sample benchmark to compile and run, add the missing parenthesis and re-define the two functions:
import Benchmark
let benchmarks = {
Benchmark("Minimal benchmark") { benchmark in
// measure something here
}
func defaultCounter() -> Int {
10
}
func dummyCounter(_ count: Int) {
for index in 0 ..< count {
blackHole(index)
}
}
Benchmark("All metrics, full concurrency, async",
configuration: .init(metrics: BenchmarkMetric.all,
maxDuration: .seconds(10))) { benchmark in
let _ = await withTaskGroup(of: Void.self, returning: Void.self, body: { taskGroup in
for _ in 0..<80 {
taskGroup.addTask {
dummyCounter(defaultCounter()*1000)
}
}
for await _ in taskGroup {
}
})
}
}
@hassila What do you think the best approach is to make dummyCounter and defaultCounter available without having to re-define them inside the benchmark? I tried changing them to public
in BenchmarkRunner+Basic.swift
but this gives the error Attribute 'public' can only be used in a non-local scope. Perhaps changing their location to be under Sources?