diff options
Diffstat (limited to 'benchmarks/java')
-rwxr-xr-x | benchmarks/java/pom.xml | 150 | ||||
-rwxr-xr-x | benchmarks/java/src/main/java/com/google/protobuf/ProtoBench.java (renamed from benchmarks/java/src/main/java/com/google/protocolbuffers/ProtoBench.java) | 13 | ||||
-rwxr-xr-x | benchmarks/java/src/main/java/com/google/protobuf/ProtoBenchCaliper.java (renamed from benchmarks/java/src/main/java/com/google/protocolbuffers/ProtoBenchCaliper.java) | 29 |
3 files changed, 52 insertions, 140 deletions
diff --git a/benchmarks/java/pom.xml b/benchmarks/java/pom.xml index e19f3f59..3afeebca 100755 --- a/benchmarks/java/pom.xml +++ b/benchmarks/java/pom.xml @@ -1,85 +1,59 @@ - <?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Copyright 2011 Google Inc. - ~ - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> -<!-- <parent> - <groupId>com.google.protobuf</groupId> - <artifactId>protobuf-parent</artifactId> - <version>3.5.0</version> - </parent> - - <packaging>pom</packaging> --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> <artifactId>protobuf-java-benchmark</artifactId> - <groupId>com.google.protocolbuffers</groupId> + <groupId>com.google.protobuf</groupId> <version>1.0.0</version> <name>Protocol Buffers [Benchmark]</name> - <description> - The benchmark tools for Protobuf Java. - </description> - + <description>The benchmark tools for Protobuf Java.</description> + <dependencies> <dependency> - <groupId>com.google.protobuf</groupId> - <artifactId>protobuf-java</artifactId> - <version>3.5.0</version> - </dependency> - <dependency> - <groupId>com.google.caliper</groupId> - <artifactId>caliper</artifactId> - <version>1.0-beta-2</version> - </dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-java</artifactId> + <version>3.5.0</version> + </dependency> + <dependency> + <groupId>com.google.caliper</groupId> + <artifactId>caliper</artifactId> + <version>1.0-beta-2</version> + </dependency> </dependencies> - + <build> <pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-assembly-plugin</artifactId> - <version>2.4.1</version> - <configuration> - <!-- get all project dependencies --> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - <!-- MainClass in mainfest make a executable jar --> - <archive> - <manifest> - <mainClass>com.mkyong.core.utils.App</mainClass> - </manifest> - </archive> - - </configuration> - <executions> - <execution> - <id>make-assembly</id> - <!-- bind to the packaging phase --> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>2.4.1</version> + <configuration> + <!-- get all project dependencies --> + <descriptorRefs> + <descriptorRef>jar-with-dependencies</descriptorRef> + </descriptorRefs> + <!-- MainClass in mainfest make a executable jar --> + <archive> + <manifest> + <mainClass>com.mkyong.core.utils.App</mainClass> + </manifest> + </archive> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <!-- bind to the packaging phase --> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> @@ -114,35 +88,7 @@ </execution> </executions> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-shade-plugin</artifactId> - <version>2.3</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>shade</goal> - </goals> - <configuration> - <shadedArtifactAttached>true</shadedArtifactAttached> - <shadedClassifierName>all</shadedClassifierName> - <transformers> - <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> - <manifestEntries> - <Premain-Class>com.google.monitoring.runtime.instrumentation.AllocationInstrumenter</Premain-Class> - <Can-Redefine-Classes>true</Can-Redefine-Classes> - <Can-Retransform-Classes>true</Can-Retransform-Classes> - </manifestEntries> - </transformer> - </transformers> - </configuration> - </execution> - </executions> - </plugin> </plugins> </pluginManagement> </build> - -</project> - +</project>
\ No newline at end of file diff --git a/benchmarks/java/src/main/java/com/google/protocolbuffers/ProtoBench.java b/benchmarks/java/src/main/java/com/google/protobuf/ProtoBench.java index 72f2d629..abd9200e 100755 --- a/benchmarks/java/src/main/java/com/google/protocolbuffers/ProtoBench.java +++ b/benchmarks/java/src/main/java/com/google/protobuf/ProtoBench.java @@ -29,7 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -package com.google.protocolbuffers; +package com.google.protobuf; import com.google.caliper.BeforeExperiment; import com.google.caliper.Benchmark; @@ -93,7 +93,7 @@ public class ProtoBench { return false; } argsList.add("-DdataFile=" + file); - argsList.add("com.google.protocolbuffers.ProtoBenchCaliper"); + argsList.add("com.google.protobuf.ProtoBenchCaliper"); try { String args[] = new String[argsList.size()]; @@ -121,17 +121,9 @@ public class ProtoBench { } else if (benchmarkDataset.getMessageName(). equals("benchmarks.google_message3.GoogleMessage3")) { temp.add("-DbenchmarkMessageType=GOOGLE_MESSAGE3"); - for (String opt : ProtoBenchCaliper - .BenchmarkMessageType.GOOGLE_MESSAGE3.getSpecificCaliperOption()) { - temp.add(opt); - } } else if (benchmarkDataset.getMessageName(). equals("benchmarks.google_message4.GoogleMessage4")) { temp.add("-DbenchmarkMessageType=GOOGLE_MESSAGE4"); - for (String opt : ProtoBenchCaliper - .BenchmarkMessageType.GOOGLE_MESSAGE4.getSpecificCaliperOption()) { - temp.add(opt); - } } else { return null; } @@ -142,6 +134,7 @@ public class ProtoBench { String benchmarkNames = "serializeToByteString,serializeToByteArray,serializeToMemoryStream" + ",deserializeFromByteString,deserializeFromByteArray,deserializeFromMemoryStream"; temp.add(benchmarkNames); + temp.add("-Cinstrument.runtime.options.timingInterval=3000ms"); return temp; } diff --git a/benchmarks/java/src/main/java/com/google/protocolbuffers/ProtoBenchCaliper.java b/benchmarks/java/src/main/java/com/google/protobuf/ProtoBenchCaliper.java index 4045b56a..546c25a1 100755 --- a/benchmarks/java/src/main/java/com/google/protocolbuffers/ProtoBenchCaliper.java +++ b/benchmarks/java/src/main/java/com/google/protobuf/ProtoBenchCaliper.java @@ -1,5 +1,5 @@ -package com.google.protocolbuffers; +package com.google.protobuf; import com.google.caliper.BeforeExperiment; import com.google.caliper.Benchmark; @@ -26,7 +26,6 @@ public class ProtoBenchCaliper { return com.google.protobuf.benchmarks.BenchmarkMessage1Proto3.GoogleMessage1 .getDefaultInstance(); } - @Override String[] getSpecificCaliperOption() { return null; } }, GOOGLE_MESSAGE1_PROTO2 { @Override ExtensionRegistry getExtensionRegistry() { return ExtensionRegistry.newInstance(); } @@ -35,7 +34,6 @@ public class ProtoBenchCaliper { return com.google.protobuf.benchmarks.BenchmarkMessage1Proto2.GoogleMessage1 .getDefaultInstance(); } - @Override String[] getSpecificCaliperOption() { return null; } }, GOOGLE_MESSAGE2 { @Override ExtensionRegistry getExtensionRegistry() { return ExtensionRegistry.newInstance(); } @@ -43,7 +41,6 @@ public class ProtoBenchCaliper { Message getDefaultInstance() { return com.google.protobuf.benchmarks.BenchmarkMessage2.GoogleMessage2.getDefaultInstance(); } - @Override String[] getSpecificCaliperOption() { return null; } }, GOOGLE_MESSAGE3 { @Override @@ -64,12 +61,6 @@ public class ProtoBenchCaliper { Message getDefaultInstance() { return benchmarks.google_message3.BenchmarkMessage3.GoogleMessage3.getDefaultInstance(); } - @Override - String[] getSpecificCaliperOption() { - String[] opt = new String[1]; - opt[0] = "-Cinstrument.runtime.options.timingInterval=3000ms"; - return opt; - } }, GOOGLE_MESSAGE4 { @Override @@ -85,17 +76,10 @@ public class ProtoBenchCaliper { Message getDefaultInstance() { return benchmarks.google_message4.BenchmarkMessage4.GoogleMessage4.getDefaultInstance(); } - @Override - String[] getSpecificCaliperOption() { - String[] opt = new String[1]; - opt[0] = "-Cinstrument.runtime.options.timingInterval=3000ms"; - return opt; - } }; abstract ExtensionRegistry getExtensionRegistry(); abstract Message getDefaultInstance(); - abstract String[] getSpecificCaliperOption(); } @Param @@ -112,8 +96,6 @@ public class ProtoBenchCaliper { private List<ByteString> inputStringList; private List<Message> sampleMessageList; private int counter; - private FileOutputStream devNull; - private CodedOutputStream reuseDevNull; @BeforeExperiment void setUp() throws IOException { @@ -135,15 +117,6 @@ public class ProtoBenchCaliper { sampleMessageList.add( defaultMessage.newBuilderForType().mergeFrom(singleInputData, extensions).build()); } - devNull = null; - reuseDevNull = null; - - try { - devNull = new FileOutputStream("/dev/null"); - reuseDevNull = CodedOutputStream.newInstance(devNull); - } catch (FileNotFoundException e) { - // ignore: this is probably Windows, where /dev/null does not exist - } counter = 0; } |