aboutsummaryrefslogtreecommitdiffhomepage
path: root/benchmarks
diff options
context:
space:
mode:
authorGravatar Yilun Chong <yilunchong@google.com>2018-05-21 14:56:56 -0700
committerGravatar Yilun Chong <yilunchong@google.com>2018-05-21 14:56:56 -0700
commit98e097233f1cb2978ee2e57671bcd8e0e65e0dd2 (patch)
tree9cb6dfc6271d93851bdc6d05cc7d5b5f71205c37 /benchmarks
parentc3566c68618b47777f52d2387e0dac9966ae4587 (diff)
Fix java benchmark bug, fix python library_path
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/Makefile.am14
-rwxr-xr-xbenchmarks/java/pom.xml5
-rwxr-xr-xbenchmarks/java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java32
3 files changed, 19 insertions, 32 deletions
diff --git a/benchmarks/Makefile.am b/benchmarks/Makefile.am
index 564fdab3..ed893457 100644
--- a/benchmarks/Makefile.am
+++ b/benchmarks/Makefile.am
@@ -126,8 +126,10 @@ java_benchmark_testing_files = \
java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java
javac_middleman: $(java_benchmark_testing_files) protoc_middleman protoc_middleman2
- cp -r $(srcdir)/java tmp && cd tmp/java && mvn clean compile assembly:single
- cd ../..
+ cp -r $(srcdir)/java tmp
+ mkdir -p tmp/java/lib
+ cp $(top_srcdir)/java/core/target/*.jar tmp/java/lib/protobuf-java.jar
+ cd tmp/java && mvn clean compile assembly:single -Dprotobuf.version=$(PACKAGE_VERSION) && cd ../..
@touch javac_middleman
java-benchmark: javac_middleman
@@ -137,10 +139,10 @@ java-benchmark: javac_middleman
@echo 'conf=()' >> java-benchmark
@echo 'data_files=""' >> java-benchmark
@echo 'for arg in $$@; do if [[ $${arg:0:1} == "-" ]]; then conf+=($$arg); else data_files+="$$arg,"; fi; done' >> java-benchmark
- @echo 'java -cp '"tmp/java/target/*.jar"' com.google.caliper.runner.CaliperMain com.google.protobuf.ProtoCaliperBenchmark -i runtime '"\\" >> java-benchmark
- @echo '-b serializeToByteString,serializeToByteArray,serializeToMemoryStream,'"\\" >> java-benchmark
- @echo 'deserializeFromByteString,deserializeFromByteArray,deserializeFromMemoryStream '"\\" >> java-benchmark
- @echo '-DdataFile=$${data_files:0:-1} $${conf[*]}' >> java-benchmark
+ @echo 'java -cp '\"tmp/java/target/*:$(top_srcdir)/java/core/target/*:$(top_srcdir)/java/util/target/*\"" \\" >>java-benchmark
+ @echo ' com.google.caliper.runner.CaliperMain com.google.protobuf.ProtoCaliperBenchmark -i runtime '"\\" >> java-benchmark
+ @echo ' -b serializeToByteArray,serializeToMemoryStream,deserializeFromByteArray,deserializeFromMemoryStream '"\\" >> java-benchmark
+ @echo ' -DdataFile=$${data_files:0:-1} $${conf[*]}' >> java-benchmark
@chmod +x java-benchmark
java: protoc_middleman protoc_middleman2 java-benchmark
diff --git a/benchmarks/java/pom.xml b/benchmarks/java/pom.xml
index c2cd78a1..570bd664 100755
--- a/benchmarks/java/pom.xml
+++ b/benchmarks/java/pom.xml
@@ -14,7 +14,10 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
- <version>3.5.0</version>
+ <version>${protobuf.version}</version>
+ <type>jar</type>
+ <scope>system</scope>
+ <systemPath>${project.basedir}/lib/protobuf-java.jar</systemPath>
</dependency>
<dependency>
<groupId>com.google.caliper</groupId>
diff --git a/benchmarks/java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java b/benchmarks/java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java
index 94568aea..c766d74e 100755
--- a/benchmarks/java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java
+++ b/benchmarks/java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java
@@ -5,6 +5,7 @@ import com.google.caliper.BeforeExperiment;
import com.google.caliper.AfterExperiment;
import com.google.caliper.Benchmark;
import com.google.caliper.Param;
+import com.google.caliper.api.VmOptions;
import com.google.protobuf.ByteString;
import com.google.protobuf.CodedOutputStream;
import com.google.protobuf.ExtensionRegistry;
@@ -22,6 +23,12 @@ import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
+// Caliper set CICompilerCount to 1 for making sure compilation doesn't run in parallel with itself,
+// This makes TieredCompilation not working. We just disable TieredCompilation by default. In master
+// branch this has been disabled by default in caliper:
+// https://github.com/google/caliper/blob/master/caliper-runner/src/main/java/com/google/caliper/runner/target/Jvm.java#L38:14
+// But this haven't been added into most recent release.
+@VmOptions("-XX:-TieredCompilation")
public class ProtoCaliperBenchmark {
public enum BenchmarkMessageType {
GOOGLE_MESSAGE1_PROTO3 {
@@ -152,18 +159,6 @@ public class ProtoCaliperBenchmark {
@Benchmark
- void serializeToByteString(int reps) throws IOException {
- if (sampleMessageList.size() == 0) {
- return;
- }
- for (int i = 0; i < reps; i++) {
- for (int j = 0; j < sampleMessageList.size(); j++) {
- sampleMessageList.get(j).toByteString();
- }
- }
- }
-
- @Benchmark
void serializeToByteArray(int reps) throws IOException {
if (sampleMessageList.size() == 0) {
return;
@@ -189,19 +184,6 @@ public class ProtoCaliperBenchmark {
}
@Benchmark
- void deserializeFromByteString(int reps) throws IOException {
- if (inputStringList.size() == 0) {
- return;
- }
- for (int i = 0; i < reps; i++) {
- for (int j = 0; j < inputStringList.size(); j++) {
- benchmarkMessageType.getDefaultInstance().getParserForType().parseFrom(
- inputStringList.get(j), extensions);
- }
- }
- }
-
- @Benchmark
void deserializeFromByteArray(int reps) throws IOException {
if (inputDataList.size() == 0) {
return;