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

sbt-jmh should not ignore library dependencies in Runtime configuration #126

Open
Atry opened this issue Aug 25, 2017 · 4 comments
Open

Comments

@Atry
Copy link

Atry commented Aug 25, 2017

// project/plugins.sbt
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.27")
// build.sbt
enablePlugins(JmhPlugin)

libraryDependencies += "org.slf4j" % "slf4j-jdk14" % "1.7.25" % Runtime

libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.25"
package mypackage
import org.slf4j.LoggerFactory
import org.openjdk.jmh.annotations.Benchmark
class MyBenchmark {
  @Benchmark
  def testLog(): Unit = {
    val logger = LoggerFactory.getLogger(classOf[MyBenchmark])
    logger.info("Hello World")
  }
}
> jmh:run
[info] Compiling 1 Scala source to /private/tmp/jmh/target/scala-2.10/classes...
Processing 1 classes from /private/tmp/jmh/target/scala-2.10/classes with "reflection" generator
Writing out Java source to /private/tmp/jmh/target/scala-2.10/src_managed/jmh and resources to /private/tmp/jmh/target/scala-2.10/resource_managed/jmh
[info] Compiling 5 Java sources to /private/tmp/jmh/target/scala-2.10/classes...
[info] Running org.openjdk.jmh.Main 
[info] # JMH version: 1.19
[info] # VM version: JDK 1.8.0_131, VM 25.131-b11
[info] # VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/bin/java
[info] # VM options: <none>
[info] # Warmup: 20 iterations, 1 s each
[info] # Measurement: 20 iterations, 1 s each
[info] # Timeout: 10 min per iteration
[info] # Threads: 1 thread, will synchronize iterations
[info] # Benchmark mode: Throughput, ops/time
[info] # Benchmark: mypackage.MyBenchmark.testLog
[info] 
[info] # Run progress: 0.00% complete, ETA 00:06:40
[info] # Fork: 1 of 10
[error] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[error] SLF4J: Defaulting to no-operation (NOP) logger implementation
[error] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[info] # Warmup Iteration   1: 522337535.681 ops/s
[info] # Warmup Iteration   2: 499173949.962 ops/s
[info] # Warmup Iteration   3: 534586788.976 ops/s
[info] # Warmup Iteration   4: 526901701.968 ops/s
[info] # Warmup Iteration   5: 537736249.150 ops/s

Note the warning:

[error] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[error] SLF4J: Defaulting to no-operation (NOP) logger implementation
[error] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

It means the setting libraryDependencies += "org.slf4j" % "slf4j-jdk14" % "1.7.25" % Runtime does not apply to jmh:run.

@ktoso
Copy link
Member

ktoso commented Aug 28, 2017

It may be that the deps are not collected from the Runtime scope, should be a simple fix if that's it - please give it a try with a pull request?

@ktoso
Copy link
Member

ktoso commented Aug 29, 2017

You did not mention which sbt version you're using, but if 1.0 there was a bug which may relate to this which 1.0.1 fixes;

- Fixes `run in Compile` task not including `Runtime` configuration, by reimplementing
  `run` in terms of `bgRun`. [#3477][3477] by [@eed3si9n][@eed3si9n]

@Atry
Copy link
Author

Atry commented Aug 29, 2017

The sbt version is 0.13.16. Sorry I didn't mention it before.

@ktoso
Copy link
Member

ktoso commented Aug 30, 2017

Could you provide a failing test in the sbt-test directory so we could give this a shot together?

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

No branches or pull requests

2 participants