Comments (8)
Yeah the docs aren't explicit about how to do it, but you need to create a compilation for that sourceset.
kotlin {
targets {
js {
compilations.create("bench")
}
}
sourceSets {
val commonBench by creating {
dependsOn(commonMain)
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.4.0")
}
}
val jsBench by existing {
dependsOn(commonBench)
dependsOn(jsMain)
}
}
}
benchmark {
targets {
register("jsBench")
}
}
from kotlinx-benchmark.
Copied more directly from my actual project which uses the name "bench", not "benchmark"; perhaps the latter conflicts with some things kotlinx-benchmark sets up itself. (You did remove register("js")
though, right?)
from kotlinx-benchmark.
The following commit shows how I got it working in my multi-platform project based on the responses from @ephemient.
It is a minimal commit with just the changes. Make sure you read the README.md file in the commit, especially if you only have common benchmarks and no JVM-specific benchmarks.
tree-ware/tree-ware-kotlin-core@25d2841
The benchmark tasks then show up in the Gradle panel on the right (in IntelliJ IDEA) in their own category of tasks:
from kotlinx-benchmark.
Thanks! I'm unable to make this work:
> Cannot add a KotlinJsIrCompilation with name 'benchmark' as a KotlinJsIrCompilation with that name already exists.
If I remove js { compilations.create("benchmark") }
, then I get:
KotlinSourceSet with name 'jsBenchmark' not found.
If instead I remove register("jsBenchmark")
, I get:
Caused by: java.lang.IllegalStateException: Projects must be configuring
from kotlinx-benchmark.
A little hint (I still cant get this working though), targets
in kotlin { }
has to go after sourceSets { }
from kotlinx-benchmark.
That shouldn't be necessary. My actual project: https://github.com/ephemient/aoc2021/blob/main/kt/build.gradle.kts (contains a lot of extra stuff you don't care about, but it runs benchmarks on a single target's "bench" compilation/sourceset).
from kotlinx-benchmark.
If I dont, I do get
KotlinSourceSet with name 'jvmBench' not found. // jsBenchmark in your (second) case
from kotlinx-benchmark.
For those who followed @ephemient's instructions and are getting the following gradle error:
Project#afterEvaluate(Action) on project ':rest-ktor' cannot be executed in the current context.
You'll want to change the existing
to getting
from:
val jsBench by existing {
dependsOn(commonBench)
dependsOn(jsMain)
}
to:
val jsBench by getting {
dependsOn(commonBench)
dependsOn(jsMain)
}
from kotlinx-benchmark.
Related Issues (20)
- Publish sources to gradle plugins repo
- Update JMH version HOT 3
- How to run a benchmark in IntelliJ? HOT 1
- Mode average time does not provide proper results HOT 1
- Native benchmark fails on 0.4.9 HOT 3
- jvmBenchmarkJar task creates a JAR file that has "JMH" in both base and classifier parts of the file name HOT 2
- Native benchmark fails on 0.4.10 HOT 8
- Non-JVM benchmarks fail if multiple modes are specified in BenchmarkMode annotation
- Plugin's tasks ignore configured java toolchain HOT 2
- Native & WasmJs benchmark: executor incorrectly estimates the number of repetitions within each measurement iteration HOT 1
- Native benchmark: iteration counter overflow
- Add an option to pass arguments to a runtime executing benchmarks
- Improve sample projects
- Multiple issues when running on K/JS HOT 4
- Gradle tasks executing benchmarks succeed even if some benchmarks fail
- Support setting up different toolchains for different benchmark configurations
- Introduce contribution guidelines
- Support debug build configuration for K/N HOT 1
- K/N: can't define cinterop in a benchmark module
- Reporting: when running in Idea, dot in a benchmark param's name is treated like class/method separator HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotlinx-benchmark.