groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [5/7] groovy git commit: Add a benchmark for hashCode() generated using @EqualsAndHashCode when instance on which hashCode() is called has null fields and properties
Date Fri, 17 Nov 2017 11:56:04 GMT
Add a benchmark for hashCode() generated using @EqualsAndHashCode when instance on which hashCode()
is called has null fields and properties


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/dc1e5ac5
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/dc1e5ac5
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/dc1e5ac5

Branch: refs/heads/GROOVY_2_6_X
Commit: dc1e5ac5cadde6e410c967dcb5535bc327b5474f
Parents: 195a94c
Author: Marcin Erdmann <erdi84@gmail.com>
Authored: Sun Nov 12 10:25:03 2017 +0000
Committer: paulk <paulk@asert.com.au>
Committed: Fri Nov 17 21:55:36 2017 +1000

----------------------------------------------------------------------
 .../groovy/bench/GeneratedHashCodeBench.java    | 43 ++++++++++++++++++++
 .../groovy/bench/GeneratedHashCode.groovy       | 30 ++++++++++++++
 2 files changed, 73 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/dc1e5ac5/subprojects/performance/src/jmh/java/org/apache/groovy/bench/GeneratedHashCodeBench.java
----------------------------------------------------------------------
diff --git a/subprojects/performance/src/jmh/java/org/apache/groovy/bench/GeneratedHashCodeBench.java
b/subprojects/performance/src/jmh/java/org/apache/groovy/bench/GeneratedHashCodeBench.java
new file mode 100644
index 0000000..0ba4909
--- /dev/null
+++ b/subprojects/performance/src/jmh/java/org/apache/groovy/bench/GeneratedHashCodeBench.java
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.
+ */
+package org.apache.groovy.bench;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Warmup;
+
+import java.util.concurrent.TimeUnit;
+
+@Warmup(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
+@Fork(3)
+@BenchmarkMode(Mode.Throughput)
+@OutputTimeUnit(TimeUnit.MILLISECONDS)
+public class GeneratedHashCodeBench {
+
+    @Benchmark
+    public int generated_hashcode_on_instance_with_null_properties() {
+        return new GeneratedHashCode().hashCode();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/dc1e5ac5/subprojects/performance/src/test/groovy/org/apache/groovy/bench/GeneratedHashCode.groovy
----------------------------------------------------------------------
diff --git a/subprojects/performance/src/test/groovy/org/apache/groovy/bench/GeneratedHashCode.groovy
b/subprojects/performance/src/test/groovy/org/apache/groovy/bench/GeneratedHashCode.groovy
new file mode 100644
index 0000000..e67cd50
--- /dev/null
+++ b/subprojects/performance/src/test/groovy/org/apache/groovy/bench/GeneratedHashCode.groovy
@@ -0,0 +1,30 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.
+ */
+
+package org.apache.groovy.bench
+
+import groovy.transform.EqualsAndHashCode
+
+@EqualsAndHashCode(includeFields = true)
+class GeneratedHashCode {
+
+    private String field
+    String property
+
+}


Mime
View raw message