darkma773r commented on a change in pull request #60: GEOMETRY-75: Performance 
Module
URL: https://github.com/apache/commons-geometry/pull/60#discussion_r374442997
 
 

 ##########
 File path: 
commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/VectorPerformance.java
 ##########
 @@ -0,0 +1,382 @@
+/*
+ * 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.commons.geometry.examples.jmh.euclidean;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.function.DoubleSupplier;
+import java.util.function.Function;
+import java.util.function.ToDoubleFunction;
+import java.util.function.UnaryOperator;
+
+import org.apache.commons.geometry.core.Vector;
+import org.apache.commons.geometry.euclidean.oned.Vector1D;
+import org.apache.commons.geometry.euclidean.threed.Vector3D;
+import org.apache.commons.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.rng.UniformRandomProvider;
+import 
org.apache.commons.rng.sampling.distribution.ZigguratNormalizedGaussianSampler;
+import org.apache.commons.rng.simple.RandomSource;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.infra.Blackhole;
+
+/**
+ * Benchmarks for the Euclidean vector classes.
+ */
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
+@Fork(value = 1, jvmArgs = {"-server", "-Xms512M", "-Xmx512M"})
+public class VectorPerformance {
+
+    /**
+     * An array of edge numbers that will produce edge case results from 
functions:
+     * {@code +/-inf, +/-max, +/-min, +/-0, nan}.
+     */
+    private static final double[] EDGE_NUMBERS = {
+        Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.MAX_VALUE,
+        -Double.MAX_VALUE, Double.MIN_VALUE, -Double.MIN_VALUE, 0.0, -0.0, 
Double.NaN
+    };
+
+    /** String constant used to request random double values. */
+    private static final String RANDOM = "random";
+
+    /** String constant used to request a set of double values capable of 
normalization. */
+    private static final String NORMALIZABLE = "normalizable";
+
+    /** String constant used to request edge-case double values. */
+    private static final String EDGE = "edge";
+
+    /** Base class for vector inputs.
+     * @param <V> Vector implementation type
+     */
+    @State(Scope.Thread)
+    public abstract static class VectorInputBase<V extends Vector<V>> {
+
+        /** The dimension of the vector. */
+        private final int dimension;
+
+        /** Factory function used to create vectors from arrays of doubles. */
+        private final Function<double[], V> vectorFactory;
+
+        /** The number of vectors in the input list. */
+        @Param({"1000"})
 
 Review comment:
   Good point. Done.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to