ordo-one / package-benchmark

Swift benchmark runner with many performance metrics and great CI support
Apache License 2.0
326 stars 25 forks source link

Add new command for generating executableTarget and source boilerplate for new benchmarks #129

Closed hassila closed 1 year ago

hassila commented 1 year ago

Something like

swift package benchmark init MyBenchmark

  1. creates the Benchmarks/MyBenchmark directory

  2. creates the Benchmarks/MyBenchmark/MyBenchmark.swift source file with the boilerplate:

import Benchmark
import Foundation

let benchmarks = {
    Benchmark.defaultConfiguration = .init(scalingFactor: .kilo)

    Benchmark("SomeBenchmark") { benchmark in
        for _ in benchmark.scaledIterations {
            blackHole(Date()) // replace this line with your own benchmark
        }
    }
}
  1. generates this to standard out (preferably so we can pipe it to pbcopy) :
        // MyBenchmark benchmark target
        .executableTarget(
            name: "MyBenchmark",
            dependencies: [
                .product(name: "Benchmark", package: "package-benchmark"),
                .product(name: "BenchmarkPlugin", package: "package-benchmark"),
            ],
            path: "Benchmarks/MyBenchmark"
        ),

Which can then just be copy-pasted into Package.swift and we're ready to go

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 1.4.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: