forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e05d3f
commit 3f9518d
Showing
5 changed files
with
237 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package dotty.tools.benchmarks | ||
|
||
import dotty.tools.dotc._ | ||
import core.Contexts.Context | ||
|
||
import org.openjdk.jmh.results.RunResult | ||
import org.openjdk.jmh.runner.Runner | ||
import org.openjdk.jmh.runner.options.CommandLineOptions | ||
import org.openjdk.jmh.annotations.Benchmark | ||
import org.openjdk.jmh.annotations.State | ||
import org.openjdk.jmh.annotations.Scope | ||
|
||
import org.openjdk.jmh.annotations.Setup | ||
import org.openjdk.jmh.annotations.TearDown | ||
|
||
|
||
import java.io.{File, FileOutputStream, BufferedWriter, FileWriter} | ||
import scala.collection.JavaConversions._ | ||
import scala.io.Source | ||
|
||
object Bench { | ||
val COMPILE_OPTS_FILE = "compile.txt" | ||
|
||
def main(args: Array[String]): Unit = { | ||
storeCompileOptions(args) | ||
|
||
val opts = new CommandLineOptions() // parse command line arguments, and then bend them to your will! ;-) | ||
val runner = new Runner(opts) // full access to all JMH features, you can also provide a custom output Format here | ||
|
||
/* | ||
val results = runner.run() // actually run the benchmarks | ||
val f = new FileOutputStream(new File("custom.out")) | ||
results.foreach { result: RunResult ⇒ | ||
// usually you'd use these results to report into some external aggregation tool for example | ||
f.write(s"custom reporting result: ${result.getAggregatedResult.getPrimaryResult}".getBytes("UTF-8")) | ||
} | ||
f.close() | ||
*/ | ||
} | ||
|
||
def storeCompileOptions(args: Array[String]): Unit = { | ||
val file = new File(COMPILE_OPTS_FILE) | ||
val bw = new BufferedWriter(new FileWriter(file)) | ||
bw.write(args.mkString("\n")) | ||
bw.close() | ||
} | ||
|
||
def readCompileOptions: Seq[String] = | ||
Source.fromFile(COMPILE_OPTS_FILE).getLines.toSeq | ||
} | ||
|
||
@State(Scope.Benchmark) | ||
class CompilerOptions { | ||
var opts: Array[String] = null | ||
|
||
@Setup | ||
def prepare: Unit = { | ||
opts = Bench.readCompileOptions.to[Array] | ||
} | ||
} | ||
|
||
class Worker extends Driver { | ||
override def newCompiler(implicit ctx: Context): Compiler = new Compiler | ||
|
||
@Benchmark | ||
def compile(state: CompilerOptions): Unit = { | ||
println("options: " + state.opts.mkString(", ")) | ||
super.main(state.opts) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
#!/bin/sh | ||
#/*-------------------------------------------------------------------------- | ||
# * Copyright 2012 Taro L. Saito | ||
# * | ||
# * Licensed under the Apache License, Version 2.0 (the "License"); | ||
# * you may not use this file except in compliance with the License. | ||
# * You may obtain a copy of the License at | ||
# * | ||
# * http://www.apache.org/licenses/LICENSE-2.0 | ||
# * | ||
# * Unless required by applicable law or agreed to in writing, software | ||
# * distributed under the License is distributed on an "AS IS" BASIS, | ||
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# * See the License for the specific language governing permissions and | ||
# * limitations under the License. | ||
# *--------------------------------------------------------------------------*/ | ||
|
||
if [ -z "$PROG_HOME" ] ; then | ||
## resolve links - $0 may be a link to PROG_HOME | ||
PRG="$0" | ||
|
||
# need this for relative symlinks | ||
while [ -h "$PRG" ] ; do | ||
ls=`ls -ld "$PRG"` | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
PRG="$link" | ||
else | ||
PRG="`dirname "$PRG"`/$link" | ||
fi | ||
done | ||
|
||
saveddir=`pwd` | ||
|
||
PROG_HOME=`dirname "$PRG"`/.. | ||
|
||
# make it fully qualified | ||
PROG_HOME=`cd "$PROG_HOME" && pwd` | ||
|
||
cd "$saveddir" | ||
fi | ||
|
||
|
||
cygwin=false | ||
mingw=false | ||
darwin=false | ||
case "`uname`" in | ||
CYGWIN*) cygwin=true | ||
;; | ||
MINGW*) mingw=true | ||
;; | ||
Darwin*) darwin=true | ||
if [ -z "$JAVA_VERSION" ] ; then | ||
JAVA_VERSION="CurrentJDK" | ||
else | ||
echo "Using Java version: $JAVA_VERSION" 1>&2 | ||
fi | ||
if [ -z "$JAVA_HOME" ] ; then | ||
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home | ||
fi | ||
JAVA_OPTS="$JAVA_OPTS -Xdock:name=\"${PROG_NAME}\" -Xdock:icon=\"$PROG_HOME/{{{MAC_ICON_FILE}}}\" -Dapple.laf.useScreenMenuBar=true" | ||
JAVACMD="`which java`" | ||
;; | ||
esac | ||
|
||
# Resolve JAVA_HOME from javac command path | ||
if [ -z "$JAVA_HOME" ]; then | ||
javaExecutable="`which javac`" | ||
if [ -n "$javaExecutable" -a -f "$javaExecutable" -a ! "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then | ||
# readlink(1) is not available as standard on Solaris 10. | ||
readLink=`which readlink` | ||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then | ||
javaExecutable="`readlink -f \"$javaExecutable\"`" | ||
javaHome="`dirname \"$javaExecutable\"`" | ||
javaHome=`expr "$javaHome" : '\(.*\)/bin'` | ||
JAVA_HOME="$javaHome" | ||
export JAVA_HOME | ||
fi | ||
fi | ||
fi | ||
|
||
|
||
if [ -z "$JAVACMD" ] ; then | ||
if [ -n "$JAVA_HOME" ] ; then | ||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
# IBM's JDK on AIX uses strange locations for the executables | ||
JAVACMD="$JAVA_HOME/jre/sh/java" | ||
else | ||
JAVACMD="$JAVA_HOME/bin/java" | ||
fi | ||
else | ||
JAVACMD="`which java`" | ||
fi | ||
fi | ||
|
||
if [ ! -x "$JAVACMD" ] ; then | ||
echo "Error: JAVA_HOME is not defined correctly." | ||
echo " We cannot execute $JAVACMD" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$JAVA_HOME" ] ; then | ||
echo "Warning: JAVA_HOME environment variable is not set." | ||
fi | ||
|
||
CLASSPATH_SUFFIX="" | ||
# Path separator used in EXTRA_CLASSPATH | ||
PSEP=":" | ||
|
||
# For Cygwin, switch paths to Windows-mixed format before running java | ||
if $cygwin; then | ||
[ -n "$PROG_HOME" ] && | ||
PROG_HOME=`cygpath -am "$PROG_HOME"` | ||
[ -n "$JAVA_HOME" ] && | ||
JAVA_HOME=`cygpath -am "$JAVA_HOME"` | ||
CLASSPATH_SUFFIX=";" | ||
PSEP=";" | ||
fi | ||
|
||
# For Migwn, ensure paths are in UNIX format before anything is touched | ||
if $mingw ; then | ||
[ -n "$PROG_HOME" ] && | ||
PROG_HOME="`(cd "$PROG_HOME"; pwd -W | sed 's|/|\\\\|g')`" | ||
[ -n "$JAVA_HOME" ] && | ||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd -W | sed 's|/|\\\\|g')`" | ||
CLASSPATH_SUFFIX=";" | ||
PSEP=";" | ||
fi | ||
|
||
|
||
PROG_NAME={{{PROG_NAME}}} | ||
PROG_VERSION={{{PROG_VERSION}}} | ||
PROG_REVISION={{{PROG_REVISION}}} | ||
|
||
eval exec "\"$JAVACMD\"" \ | ||
{{{JVM_OPTS}}} \ | ||
${JAVA_OPTS} \ | ||
{{^EXPANDED_CLASSPATH}} | ||
-Xbootclasspath/a:"'{{{EXTRA_CLASSPATH}}}${PROG_HOME}/lib/*${CLASSPATH_SUFFIX}'" \ | ||
{{/EXPANDED_CLASSPATH}} | ||
{{#EXPANDED_CLASSPATH}} | ||
-Xbootclasspath/a:"'{{{EXTRA_CLASSPATH}}}{{{EXPANDED_CLASSPATH}}}${CLASSPATH_SUFFIX}'" \ | ||
{{/EXPANDED_CLASSPATH}} | ||
-Dprog.home="'${PROG_HOME}'" \ | ||
-Dprog.version="${PROG_VERSION}" \ | ||
-Dprog.revision="${PROG_REVISION}" \ | ||
{{{MAIN_CLASS}}} \"\$@\" | ||
exit $? |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.