Comments (6)
It is possible to keep tests for example in src/test/scala directory?
To answer the OP's (@tomqaz) question, the following code in build.sbt
worked for me:
sourceDirectory in Jmh := (sourceDirectory in Test).value
classDirectory in Jmh := (classDirectory in Test).value
dependencyClasspath in Jmh := (dependencyClasspath in Test).value
from sbt-jmh.
We're just integrating a previously external jmh project into our multimodule project, so that it's kept in sync with code changes and lower the barrier to run benchmarks after changes. Because our benchmarks depend on the test artifact of another module (which provides e.g. scalacheck generators) and Intellij does not support "compile->test" dependencies (it just ignores the dependency) we're also "forced" to integrate jmh into the test configuration.
Here's a "hack" that seems to do the trick:
In our multimodule build.sbt we have this dependency:
lazy val microbench = project.dependsOn(otherModule % "compile;compile->test").enablePlugins(JmhPlugin)
In microbench/build.sbt:
sourceDirectory in Jmh := (sourceDirectory in Test).value
// JmhPlugin.generateJmhSourcesAndResources uses (classDirectory in Compile).value
classDirectory in Compile := (classDirectory in Test).value
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.12.1" // must be in Compile scope, otherwise JmhBytecodeGenerator fails with CNFE org/scalacheck/Gen
// Running a clean 'jmh:run' resulted in 'Exception in thread "main" java.lang.RuntimeException: ERROR: Unable to find the resource: /META-INF/BenchmarkList'
// which could be fixed with a prior 'jmh:compile'. Here we rewire tasks to that a clean 'jmh:run' is possible...
Keys.compile in Jmh <<= (Keys.compile in Jmh) dependsOn (Keys.compile in Test)
run in Jmh <<= (run in Jmh) dependsOn (Keys.compile in Jmh)
Hopefully this helps others until we have a better solution.
from sbt-jmh.
What tests?
Benchmarks are not tests.
Technically you could, but I'd rather not suggest that (just override the settings)
from sbt-jmh.
Which setting would one need to override for using a custom source directory that contains the benchmarks (such as src/benchmarks
)? I've tried sourceDirectory in Jmh := ...
and sourceDirectory in (Jmh, compile) := ...
but none of that worked.
I guess moving the benchmark code into its own module/project is a decent solution as well, but that would require making it a multi-module sbt project for some people :-).
from sbt-jmh.
The gradle plugin for JMH (https://github.com/melix/jmh-gradle-plugin) uses src/jmh
in the same module.
from sbt-jmh.
Hey there,
I agree, it's a good idea - would be breaking for many people though hm...
Reason for keeping them in a different project is to avoid compiling them if you don't work on on them.
Would you like to contrib this fix? I'm a bit overloaded right now?
from sbt-jmh.
Related Issues (20)
- Add recommended jvm options in async profiler HOT 2
- missing tag for 0.3.4 on GitHub HOT 1
- Cannot run JMH benchmarks with async-profiler for versions 0.3.5 and 0.3.6 HOT 1
- Version 0.3.5 JFR profile java.lang.UnsupportedClassVersionError on Java 8 HOT 3
- Tab completion for jmh parameters
- CI broken: unable to install oraclejdk8 HOT 4
- Request for feature: Cross-Versions benchmarking HOT 2
- Canceling execution does not work on Windows
- Error when trying to use Flight Recorder HOT 5
- Scala 2.13 support is missing ? HOT 1
- Benchmark compilation fails if java.sql.ResultSet is used HOT 4
- Is it possible to set `bspEnable := false` by default? HOT 1
- publish to maven central instead of bintray HOT 5
- jmh:run caused Unable to find the resource: /META-INF/BenchmarkList in multiple projects
- Specifying javaHome per configuration
- Log4j Dependencies not being passed to the Benchmark
- `Test / skip := true` leads to `java.lang.IllegalArgumentException: Benchmark does not match a class`
- Upgrade project/build.properties to use SBT 1.9.0 HOT 2
- How to use async-profiler with multiple options HOT 6
- Forking JMH may fail on Windows with "CreateProcess error=206, The filename or extension is too long" 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 sbt-jmh.