Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run specific class or function #281

Open
theapache64 opened this issue Dec 2, 2024 · 3 comments
Open

Run specific class or function #281

theapache64 opened this issue Dec 2, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@theapache64
Copy link

How can I run specific benchmark class or function? I am looking for something like

./gradlew benchmark -Pbenchmarks="*Day1Benchmark*substringSolution"
@fzhinkin
Copy link
Contributor

fzhinkin commented Dec 2, 2024

@theapache64, right now, the only way to filter benchmark is by creating a new (or updating existing) configuration. See include/exclude options here.

For JVM, however, you can generate a benchmarks Jar and use it directly, and pass an RE to filter benchmarks.

@fzhinkin fzhinkin added the enhancement New feature or request label Dec 2, 2024
@theapache64
Copy link
Author

Oops! That sounds like pain... :D Looking forward to some IDE magic!... Thanks for the suggestion though

@teenriot
Copy link

teenriot commented Dec 15, 2024

"That sounds like pain"

Thats what i thought too. But how often do you create new Benchmarks? I simply made a gradle function to register a specific benchmark subset. From there its a gradle one liner for every specific run you need. Thats manageable without wasting time or ruining your gradle script.

benchmark {
    targets {
        register("benchmark")
    }

    configurations {
        registerStartsWith("####Playground")
        registerStartsWith("CreateUnmodifiableEmpty")
        registerStartsWith("CreateUnmodifiableFromVararg")
        ...
    }
}

fun NamedDomainObjectContainerScope<BenchmarkConfiguration>.registerStartsWith(startsWith : String) {
    val filterName = startsWith.substringAfterLast("#").substringAfterLast("_")
    val filter = "(?i)${Regex.escape(filterName)}.*"
    register(startsWith + "_accurate") {
        include(filter)
        advanced("jvmForks", "definedByJmh")
        warmups = 5
        iterations = 10
        iterationTime = 1000
        iterationTimeUnit = "ms"
    }
    register(startsWith + "_normal") {
        include(filter)
        warmups = 5
        iterations = 10
        iterationTime = 500
        iterationTimeUnit = "ms"
    }
    register(startsWith + "_quick") {
        include(filter)
        warmups = 3
        iterations = 3
        iterationTime = 500
        iterationTimeUnit = "ms"
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants