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

Onboarding feedback #98

Closed
koperagen opened this issue Sep 17, 2022 · 2 comments
Closed

Onboarding feedback #98

koperagen opened this issue Sep 17, 2022 · 2 comments
Assignees

Comments

@koperagen
Copy link

koperagen commented Sep 17, 2022

It wasn't easy to get this working in JVM project :(
Adding a plugin and runtime library wasn't enough for JHM annotations to resolve
id("org.jetbrains.kotlinx.benchmark") version "0.4.4"
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime-jvm:0.4.4")

So i tried to add JHM explicitly, picked the latest version
implementation("org.openjdk.jmh:jmh-core:1.35")

Then i followed README and came up with this

benchmark {
    targets {
        register("main")
    }

    configurations {
        val main by getting { // main configuration is created automatically, but you can change its defaults
            warmups = 20 // number of warmup iterations
            iterations = 10 // number of iterations
            iterationTime = 3 // time in seconds per iteration
        }
    }
}

copy-pasted a sample benchmark from https://github.com/Kotlin/kotlinx-benchmark/tree/master/examples/kotlin

But got this error
/home/nikitak/IdeaProjects/pelagie/build/benchmarks/main/sources/org/generated/TestBenchmark_sqrtBenchmark_jmhTest.java:129: error: incompatible types: possible lossy conversion from double to long

I checked example once again and found that JHM version is specified inside the target https://github.com/Kotlin/kotlinx-benchmark/blob/master/examples/kotlin/build.gradle

benchmark {
    // Setup configurations
    targets {
        // This one matches sourceSet name above
        register("benchmarks") {
            jmhVersion = "1.21"
        }
    }
}

I changed target configuration and commented out explicit JHM dependency and now everything is working

register("main") {
          val a: BenchmarkTarget = this as kotlinx.benchmark.gradle.JvmBenchmarkTarget
          jmhVersion = "1.21"
}

But actually i can just leave it as:

register("main") 

So the problem is that for library to resolve i also had to register a target! I didn't think about it, tried to fix resolve another way and ran into a problem with newer versions of JHM being incompatible with generated code =( I tried to downgrade JHM to 1.27, but it also didn't work

Another pain point was that default build script language for Kotlin project is, well, Kotlin, but all examples are in Groovy.

@qwwdfsad
Copy link
Contributor

Thanks!

@qurbonzoda please take it into account

@qurbonzoda
Copy link
Collaborator

Hi @koperagen,

Thanks for the feedback! Since your report, we have significantly improved the documentation. Specifically, for setting up benchmarks in a JVM project, we have a separate guide available here. Some other aspects still need improvement, though, e.g., sample projects. We have a separate issue for tracking this activity: #183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants