forked from scala/compiler-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sbt
177 lines (158 loc) · 6.38 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import java.io.BufferedInputStream
import java.io.StringReader
name := "compiler-benchmark"
version := "1.0-SNAPSHOT"
val dottyVersion = settingKey[String]("Dotty version to be benchmarked.")
dottyVersion in ThisBuild := sys.env.getOrElse("DOTC_VERSION",
dottyLatestNightlyBuild.get)
scalaVersion in ThisBuild := sys.env.getOrElse("SCALAC_VERSION", latestScalacVersion)
// Convenient access to builds from PR validation
resolvers ++= (
if (scalaVersion.value.endsWith("-SNAPSHOT"))
List(
"pr-scala snapshots old" at "http://private-repo.typesafe.com/typesafe/scala-pr-validation-snapshots/",
"pr-scala snapshots" at "https://scala-ci.typesafe.com/artifactory/scala-pr-validation-snapshots/",
Resolver.mavenLocal,
Resolver.sonatypeRepo("snapshots")
)
else
Nil
)
lazy val typesafeArtifactoryResolver = Seq(
resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"
)
lazy val latestScalacVersion = sys.props.getOrElse(
"scalacVersion", {
val view = scala.io.Source.fromURL(
"https://scala-ci.typesafe.com/job/scala-2.12.x-integrate-bootstrap/lastSuccessfulBuild/artifact/jenkins.properties/*view*/")
val props = new java.util.Properties()
props.load(new StringReader(view.mkString))
val version = props.getProperty("version")
println("Latest Scala nightly version: " + Some(version))
version
}
)
lazy val infrastructure = project
.enablePlugins(JmhPlugin)
.settings(
typesafeArtifactoryResolver,
description := "Infrastrucuture to persist benchmark results annotated with metadata from Git",
crossPaths := false,
libraryDependencies ++= Seq(
"org.influxdb" % "influxdb-java" % "2.5", // TODO update to 2.6 when released for fix for https://github.com/influxdata/influxdb-java/issues/269
"org.eclipse.jgit" % "org.eclipse.jgit" % "4.6.0.201612231935-r",
"com.google.guava" % "guava" % "21.0",
"org.apache.commons" % "commons-lang3" % "3.5",
"com.typesafe" % "config" % "1.3.1",
"org.slf4j" % "slf4j-api" % "1.7.24",
"org.slf4j" % "log4j-over-slf4j" % "1.7.24",
"ch.qos.logback" % "logback-classic" % "1.2.1"
)
)
lazy val dotcRuntime = project
.in(file("dotc-runtime"))
.settings(
scalaBinaryVersion := "0.2",
scalaVersion := dottyVersion.value,
libraryDependencies += "ch.epfl.lamp" % "dotty-compiler_0.2" % dottyVersion.value,
libraryDependencies += "ch.epfl.lamp" % "dotty-library_0.2" % dottyVersion.value
)
lazy val scalacRuntime = project
.in(file("scalac-runtime"))
.settings(
typesafeArtifactoryResolver,
libraryDependencies += ScalaArtifacts.Organization % ScalaArtifacts.CompilerID % latestScalacVersion,
libraryDependencies += ScalaArtifacts.Organization % ScalaArtifacts.LibraryID % latestScalacVersion
)
lazy val compilation = project
.enablePlugins(JmhPlugin)
.settings(
ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) },
description := "Black box benchmark of the compilers",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % Test,
fork in run := true,
buildInfoKeys := Seq[BuildInfoKey](
dottyVersion,
BuildInfoKey.map(fullClasspath.in(dotcRuntime, Compile)) {
case (_, cp) =>
val dottyClasspath = cp.map(_.data.getAbsolutePath)
"dotcClasspath" -> dottyClasspath
},
BuildInfoKey.map(fullClasspath.in(scalacRuntime, Compile)) {
case (_, cp) =>
val scalacClasspath = cp.map(_.data.getAbsolutePath)
"scalacClasspath" -> scalacClasspath
}
)
)
.enablePlugins(BuildInfoPlugin)
.dependsOn(infrastructure)
lazy val micro = project
.enablePlugins(JmhPlugin)
.settings(
description := "Finer grained benchmarks of compiler internals",
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value
)
lazy val jvm = project
.enablePlugins(JmhPlugin)
.settings(
description := "Pure Java benchmarks for demonstrating performance anomalies independent from the Scala language/library",
autoScalaLibrary := false,
crossPaths := false
)
val ui = project.settings(
scalaVersion := "2.11.8",
libraryDependencies += "com.github.tototoshi" %% "scala-csv" % "1.3.3",
libraryDependencies += "com.h2database" % "h2" % "1.4.192"
)
lazy val DottyRef = ".*-([^-]+)-NIGHTLY".r
lazy val ScalaRef = ".*-([^-]+)".r
lazy val timestamp =
new java.text.SimpleDateFormat("yyyyMMdd_kkmmss")
.format(new java.util.Date())
lazy val batchTasks = taskKey[List[String]]("")
batchTasks := tasks
lazy val tasks = {
val dottyLatestVersion @ DottyRef(dottyRef) = dottyLatestNightlyBuild.get
val ScalaRef(scalaRef) = latestScalacVersion
for {
(compiler, sourceDirectory, version, ref) <- List(
("Dotc", "dotty", dottyLatestVersion, dottyRef),
("Scalac", "scala", latestScalacVersion, scalaRef)
)
scalaVersion = s" -DscalaVersion=$version"
baseSourceDir = sys.props
.getOrElse("gitrepos", "/home/benchs")
.stripSuffix("/")
benchmarkTimestamp = s" -DbenchmarkTimestamp=$timestamp"
scalaRef = s" -DscalaRef=$ref"
localdir = s" -Dgit.localdir=$baseSourceDir/$sourceDirectory"
sysProps = s"$scalaVersion $scalaRef $localdir $benchmarkTimestamp"
runUpload = s"compilation/jmh:runMain $sysProps scala.bench.UploadingRunner "
inputProject <- List("vector", "squants", "paiges")
source = s"-p source=$inputProject"
bench = s"(Cold|Warm|Hot)${compiler}Benchmark"
} yield s"""; clean ; $runUpload $bench $source """.stripMargin
}
commands += Command.command("runBatch") { s =>
tasks.foldLeft(s) {
case (state, task) =>
println(s"Running command: $task")
task :: state
}
}
addCommandAlias("hot-scalac", "compilation/jmh:run HotScalacBenchmark")
addCommandAlias("cold-scalac", "compilation/jmh:run ColdScalacBenchmark")
addCommandAlias("warm-scalac", "compilation/jmh:run WarmScalacBenchmark")
addCommandAlias("hot-dotc", "compilation/jmh:run HotDotcBenchmark")
addCommandAlias("cold-dotc", "compilation/jmh:run ColdDotcBenchmark")
addCommandAlias("warm-dotc", "compilation/jmh:run WarmDotcBenchmark")
commands += runBoth("cold")
commands += runBoth("warm")
commands += runBoth("hot")
def runBoth(cmd: String) = Command.args(cmd, cmd) {
case (state, args) =>
s"$cmd-dotc " + args.mkString(" ") ::
s"$cmd-scalac " + args.mkString(" ") ::
state
}