Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

moved minitest into separate class

  • Loading branch information...
commit 324ea21fea482b410e7de2f008c2f9bd194f8c65 1 parent da3f288
@karussell authored
View
2  pom.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>de.jetslide</groupId>
+ <groupId>de.jetsli</groupId>
<artifactId>graphhopper</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
View
84 src/main/java/de/jetsli/graph/reader/MiniTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2012 Peter Karich info@jetsli.de
+ *
+ * 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.
+ */
+package de.jetsli.graph.reader;
+
+import de.jetsli.graph.util.Helper;
+import de.jetsli.graph.util.StopWatch;
+import java.util.Date;
+import java.util.Random;
+
+/**
+ * @author Peter Karich
+ */
+public class MiniTest {
+
+ protected int max = 20;
+ protected String name = "";
+ protected boolean showProgress = true;
+ protected Random random = new Random(0);
+
+ public MiniTest(String name) {
+ this.name = name;
+ }
+
+ public MiniTest setShowProgress(boolean showProgress) {
+ this.showProgress = showProgress;
+ return this;
+ }
+
+ public MiniTest setSeed(long seed) {
+ random.setSeed(seed);
+ return this;
+ }
+
+ public MiniTest setMax(int max) {
+ this.max = max;
+ return this;
+ }
+
+ public void start() {
+ int maxNo = max / 4;
+ long res = 0;
+ System.out.println(new Date() + "# start performance " + name + ", iterations:" + max);
+ StopWatch sw = new StopWatch().start();
+ for (int i = 0; i < maxNo; i++) {
+ res += doJvmInit(i);
+ }
+ if (showProgress)
+ System.out.println(new Date() + "# jvm initialized! secs/iter:" + sw.stop().getSeconds() / maxNo);
+ sw = new StopWatch().start();
+ maxNo = max;
+ float partition = 5.0F;
+ int part = (int) (maxNo / partition);
+ for (int i = 0; i < maxNo; i++) {
+ if (showProgress && i % part == 0)
+ System.out.println(new Date() + "# progress " + i * 100 / maxNo + "% => secs/iter:" + (sw.stop().start().getSeconds() / i));
+ res += doCalc(i);
+ }
+ System.out.println(new Date() + "# progress 100% in " + sw.stop().getSeconds() + " secs => secs/iter:" + sw.stop().getSeconds() / maxNo + "\n avoid jvm removal:" + res + ", memInfo:" + Helper.getMemInfo() + " " + Helper.getBeanMemInfo() + "\n");
+ }
+
+ /**
+ * @return something meaningless to avoid that jvm optimizes away the inner code
+ */
+ public long doJvmInit(int run) {
+ return doCalc(-run);
+ }
+
+ public long doCalc(int run) {
+ return run;
+ }
+}
View
68 src/main/java/de/jetsli/graph/reader/PerfTest.java
@@ -118,74 +118,6 @@ private void measureSearch(int minBits, int maxDist, int maxEPerL) {
}
}
- class MiniTest {
-
- protected int max = 20;
- protected String name = "";
- protected boolean showProgress = true;
- protected Random random = new Random(0);
-
- public MiniTest() {
- }
-
- public MiniTest(String n) {
- name = n;
- }
-
- public MiniTest setShowProgress(boolean showProgress) {
- this.showProgress = showProgress;
- return this;
- }
-
- public MiniTest setSeed(long seed) {
- random.setSeed(seed);
- return this;
- }
-
- public MiniTest setMax(int max) {
- this.max = max;
- return this;
- }
-
- public void start() {
- int maxNo = max / 4;
- long res = 0;
- System.out.println(new Date() + "# start performance " + name + ", iterations:" + max);
- StopWatch sw = new StopWatch().start();
- for (int i = 0; i < maxNo; i++) {
- res += doJvmInit(i);
- }
-
- if (showProgress)
- System.out.println(new Date() + "# jvm initialized! secs/iter:" + sw.stop().getSeconds() / maxNo);
-
- sw = new StopWatch().start();
- maxNo = max;
- float partition = 5f;
- int part = (int) (maxNo / partition);
- for (int i = 0; i < maxNo; i++) {
- if (showProgress && i % part == 0)
- System.out.println(new Date() + "# progress " + i * 100 / maxNo + "% => secs/iter:" + (sw.stop().start().getSeconds() / i));
-
- res += doCalc(i);
- }
- System.out.println(new Date() + "# progress 100% in " + sw.stop().getSeconds()
- + " secs => secs/iter:" + sw.stop().getSeconds() / maxNo + "\n avoid jvm removal:" + res
- + ", memInfo:" + Helper.getMemInfo() + " " + Helper.getBeanMemInfo() + "\n");
- }
-
- /**
- * @return something meaningless to avoid that jvm optimizes away the inner code
- */
- public long doJvmInit(int run) {
- return doCalc(-run);
- }
-
- public long doCalc(int run) {
- return run;
- }
- }
-
public static void fillQuadTree(QuadTree quadTree, Graph graph) {
// TODO LATER persist quad tree to make things faster and store osm ids instead nothing
Integer empty = new Integer(1);
Please sign in to comment.
Something went wrong with that request. Please try again.