summaryrefslogtreecommitdiff
path: root/integration/test/resources/play-json/jmh.sc
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-03-27 20:31:00 -0700
committerLi Haoyi <haoyi.sg@gmail.com>2018-03-27 20:31:00 -0700
commit0a1ba59f4956cbeb899753df3e2430752c308d1e (patch)
tree6d103d58ec34b3496f1a4dcfbc76f767a835e8d0 /integration/test/resources/play-json/jmh.sc
parent25b321ea9431590d5852366585f1691717651fea (diff)
parent277d44208fae50efc20d902c0cd6d127516cfadb (diff)
downloadmill-0a1ba59f4956cbeb899753df3e2430752c308d1e.tar.gz
mill-0a1ba59f4956cbeb899753df3e2430752c308d1e.tar.bz2
mill-0a1ba59f4956cbeb899753df3e2430752c308d1e.zip
Merge branch 'master' of github.com:lihaoyi/mill
Diffstat (limited to 'integration/test/resources/play-json/jmh.sc')
-rw-r--r--integration/test/resources/play-json/jmh.sc61
1 files changed, 61 insertions, 0 deletions
diff --git a/integration/test/resources/play-json/jmh.sc b/integration/test/resources/play-json/jmh.sc
new file mode 100644
index 00000000..76ed43fc
--- /dev/null
+++ b/integration/test/resources/play-json/jmh.sc
@@ -0,0 +1,61 @@
+import ammonite.ops._
+import mill._, scalalib._, modules._
+
+trait Jmh extends ScalaModule {
+
+ def ivyDeps = super.ivyDeps() ++ Agg(ivy"org.openjdk.jmh:jmh-core:1.19")
+
+ def runJmh(args: String*) = T.command {
+ val (_, resources) = generateBenchmarkSources()
+ Jvm.interactiveSubprocess(
+ "org.openjdk.jmh.Main",
+ classPath = (runClasspath() ++ generatorDeps()).map(_.path) ++
+ Seq(compileGeneratedSources().path, resources),
+ mainArgs = args,
+ workingDir = T.ctx.dest
+ )
+ }
+
+ def compileGeneratedSources = T {
+ val dest = T.ctx.dest
+ val (sourcesDir, _) = generateBenchmarkSources()
+ val sources = ls.rec(sourcesDir).filter(_.isFile)
+ %%("javac",
+ sources.map(_.toString),
+ "-cp",
+ (runClasspath() ++ generatorDeps()).map(_.path.toString).mkString(":"),
+ "-d",
+ dest)(wd = dest)
+ PathRef(dest)
+ }
+
+ // returns sources and resources directories
+ def generateBenchmarkSources = T {
+ val dest = T.ctx().dest
+
+ val sourcesDir = dest / 'jmh_sources
+ val resourcesDir = dest / 'jmh_resources
+
+ rm(sourcesDir)
+ mkdir(sourcesDir)
+ rm(resourcesDir)
+ mkdir(resourcesDir)
+
+ Jvm.subprocess(
+ "org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator",
+ (runClasspath() ++ generatorDeps()).map(_.path),
+ mainArgs = Array(
+ compile().classes.path,
+ sourcesDir,
+ resourcesDir,
+ "default"
+ ).map(_.toString)
+ )
+
+ (sourcesDir, resourcesDir)
+ }
+
+ def generatorDeps = resolveDeps(
+ T { Agg(ivy"org.openjdk.jmh:jmh-generator-bytecode:1.19") }
+ )
+}