diff options
author | Mads Ager <ager@google.com> | 2022-03-30 13:26:50 +0000 |
---|---|---|
committer | Jiaxiang Chen <roaringacw@gmail.com> | 2022-03-30 10:57:09 -0700 |
commit | 5588d1a7bf7ae97200b89afe21faafbf6521159f (patch) | |
tree | 8b7fc4b1c7dd73024ed469a52c67d500091f3111 /benchmark | |
parent | f15c75346ec6dca9987ad23f35d571a64ac14c9d (diff) | |
download | ksp-5588d1a7bf7ae97200b89afe21faafbf6521159f.tar.gz |
Benchmark script fixes.
To build the benchmark runner and ksp:
`./benchmark/build.sh`
To build the TachiyomiExhaustive benchmark libs:
`ANDROID_SDK_ROOT=<path to root> ./benchmark/TachiyomiExhaustive/build.sh`
To run the benchmark:
`./benchmark/runner/runner.sh TachiyomiExhaustive ..`
The second argument to runner.sh is the relative path from the script
directory to where the Tachiyomi source and libs is located. This
will be different on the benchmark runners, so needs to be passed
in.
Diffstat (limited to 'benchmark')
-rwxr-xr-x | benchmark/TachiyomiExhaustive/build.sh | 27 | ||||
-rw-r--r-- | benchmark/TachiyomiExhaustive/tachi.patch (renamed from benchmark/bench-tachi/tachi.patch) | 0 | ||||
-rwxr-xr-x | benchmark/bench-tachi/build.sh | 28 | ||||
-rwxr-xr-x | benchmark/build.sh | 33 | ||||
-rwxr-xr-x | benchmark/runner/runner.sh | 36 | ||||
-rw-r--r-- | benchmark/src/main/kotlin/com/google/devtools/ksp/BenchRunner.kt | 13 |
6 files changed, 66 insertions, 71 deletions
diff --git a/benchmark/TachiyomiExhaustive/build.sh b/benchmark/TachiyomiExhaustive/build.sh new file mode 100755 index 00000000..bfd8be31 --- /dev/null +++ b/benchmark/TachiyomiExhaustive/build.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Copyright 2022 Google LLC +# +# 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. +# + +set -e +SCRIPT_DIR=$(dirname "$(realpath $0)") +ROOT=$SCRIPT_DIR/../.. +cd $SCRIPT_DIR +git clone https://github.com/inorichi/tachiyomi.git +cd tachiyomi +git checkout 938339690eecdfe309d83264b6a89aff3c767687 +git apply $SCRIPT_DIR/tachi.patch +./gradlew :app:copyDepsDevDebug +mkdir -p $SCRIPT_DIR/lib && cp app/build/output/devDebug/lib/* $SCRIPT_DIR/lib diff --git a/benchmark/bench-tachi/tachi.patch b/benchmark/TachiyomiExhaustive/tachi.patch index 3903916c..3903916c 100644 --- a/benchmark/bench-tachi/tachi.patch +++ b/benchmark/TachiyomiExhaustive/tachi.patch diff --git a/benchmark/bench-tachi/build.sh b/benchmark/bench-tachi/build.sh deleted file mode 100755 index 05034905..00000000 --- a/benchmark/bench-tachi/build.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -/* - * Copyright 2022 Google LLC - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * - * 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. - */ - -set -e -SCRIPT_DIR=$(dirname "$(realpath $0)") -ROOT=$SCRIPT_DIR/../.. -cd $SCRIPT_DIR -git clone https://github.com/inorichi/tachiyomi.git -cd tachiyomi -git checkout 938339690eecdfe309d83264b6a89aff3c767687 -git apply $SCRIPT_DIR/tachi.patch -./gradlew :app:copyDepsDevDebug -mkdir -p $SCRIPT_DIR/lib && cp app/build/output/devDebug/lib/* $SCRIPT_DIR/lib diff --git a/benchmark/build.sh b/benchmark/build.sh index 41485d26..c7e98f7a 100755 --- a/benchmark/build.sh +++ b/benchmark/build.sh @@ -1,24 +1,21 @@ #!/bin/bash -/* - * Copyright 2022 Google LLC - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * - * 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. - */ + +# Copyright 2022 Google LLC +# +# 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. set -e SCRIPT_DIR=$(dirname "$(realpath $0)") -BENCHMARK=$1 ROOT=$SCRIPT_DIR/.. cd $SCRIPT_DIR rm -rf runner/out runner/processor-1.0-SNAPSHOT.jar @@ -26,8 +23,6 @@ rm -rf runner/out runner/processor-1.0-SNAPSHOT.jar cd $SCRIPT_DIR/exhaustive-processor ./gradlew build cp processor/build/libs/processor-1.0-SNAPSHOT.jar ../runner/ -cd $SCRIPT_DIR/$BENCHMARK -./build.sh cd $ROOT ./gradlew -PkspVersion=2.0.255 clean publishAllPublicationsToTestRepository cp -a build/repos/test/. $ROOT/benchmark/runner diff --git a/benchmark/runner/runner.sh b/benchmark/runner/runner.sh index 97715b6d..4034365a 100755 --- a/benchmark/runner/runner.sh +++ b/benchmark/runner/runner.sh @@ -1,26 +1,26 @@ #!/bin/bash -/* - * Copyright 2022 Google LLC - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. - * - * 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. - */ + +# Copyright 2022 Google LLC +# +# 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. set -e BENCHMARK_DIR=$1 +PREFIX=$2 + SCRIPT_DIR=$(dirname "$(realpath $0)") cd $SCRIPT_DIR -CP=../build/libs/benchmark.jar:$(echo lib/*.jar | tr ' ' ':') +CP=../build/libs/benchmark.jar:$(echo $SCRIPT_DIR/$PREFIX/$BENCHMARK_DIR/lib/*.jar | tr ' ' ':') KSP_PLUGIN_ID=com.google.devtools.ksp.symbol-processing KSP_PLUGIN_OPT=plugin:$KSP_PLUGIN_ID @@ -30,7 +30,7 @@ KSP_API_JAR=./com/google/devtools/ksp/symbol-processing-api/2.0.255/symbol-proce AP=processor-1.0-SNAPSHOT.jar mkdir -p out -find $SCRIPT_DIR/../$BENCHMARK_DIR -name "*.kt" | xargs java -cp $CP com.google.devtools.ksp.BenchRunnerKt \ +find $SCRIPT_DIR/$PREFIX/$BENCHMARK_DIR -name "*.kt" | xargs java -cp $CP com.google.devtools.ksp.BenchRunnerKt $BENCHMARK_DIR\ -kotlin-home . \ -Xplugin=$KSP_PLUGIN_JAR \ -Xplugin=$KSP_API_JAR \ diff --git a/benchmark/src/main/kotlin/com/google/devtools/ksp/BenchRunner.kt b/benchmark/src/main/kotlin/com/google/devtools/ksp/BenchRunner.kt index 7d7dba56..277c6c15 100644 --- a/benchmark/src/main/kotlin/com/google/devtools/ksp/BenchRunner.kt +++ b/benchmark/src/main/kotlin/com/google/devtools/ksp/BenchRunner.kt @@ -20,16 +20,17 @@ import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import kotlin.system.measureNanoTime fun main(args: Array<String>) { - val runs = 10 - val warmup = 10 - val benchName = "Tachiyomi" + val runs = 3 + val warmup = 3 + val benchName = args[0] + val compilerArgs = args.drop(1).toTypedArray() val cold = measureNanoTime{ - K2JVMCompiler.main(args) + K2JVMCompiler.main(compilerArgs) } / 1000000L for (i in 1..warmup) { - K2JVMCompiler.main(args) + K2JVMCompiler.main(compilerArgs) } - val hot = (1..runs).map { measureNanoTime{K2JVMCompiler.main(args)} / 1000000L } + val hot = (1..runs).map { measureNanoTime{K2JVMCompiler.main(compilerArgs)} / 1000000L } println("$benchName.Cold(RunTimeRaw): $cold ms") println("$benchName.Hot(RunTimeRaw): ${hot.minOrNull()!!} ms") } |