You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2012/02/06 14:46:23 UTC
svn commit: r1241008 - in /commons/sandbox/graph/trunk: ./ src/benchmarks/
src/benchmarks/java/ src/benchmarks/java/org/
src/benchmarks/java/org/apache/ src/benchmarks/java/org/apache/commons/
src/benchmarks/java/org/apache/commons/graph/ src/benchmark...
Author: simonetripodi
Date: Mon Feb 6 13:46:22 2012
New Revision: 1241008
URL: http://svn.apache.org/viewvc?rev=1241008&view=rev
Log:
added MST benchmarks, code provided by Thomas Neidhart
Added:
commons/sandbox/graph/trunk/src/benchmarks/
commons/sandbox/graph/trunk/src/benchmarks/java/
commons/sandbox/graph/trunk/src/benchmarks/java/org/
commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/
commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/commons/
commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/commons/graph/
commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/commons/graph/spanning/
commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmark.java (with props)
Modified:
commons/sandbox/graph/trunk/pom.xml
Modified: commons/sandbox/graph/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/pom.xml?rev=1241008&r1=1241007&r2=1241008&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/pom.xml (original)
+++ commons/sandbox/graph/trunk/pom.xml Mon Feb 6 13:46:22 2012
@@ -144,6 +144,16 @@
</testResource>
</testResources>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.12</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
@@ -155,6 +165,16 @@
<tarLongFileMode>gnu</tarLongFileMode>
</configuration>
</plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/*$*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
@@ -221,5 +241,74 @@
</site>
</distributionManagement>
</profile>
+
+ <profile>
+ <id>benchmarks</id>
+ <activation>
+ <property>
+ <name>skipBenchmarks</name>
+ <value>!true</value>
+ </property>
+ </activation>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.carrotsearch</groupId>
+ <artifactId>junit-benchmarks</artifactId>
+ <classifier>jdk15</classifier>
+ <version>0.3.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.3.158</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/src/benchmarks/java</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <jub.consumers>CONSOLE,XML,H2</jub.consumers>
+ <jub.db.file>${project.build.directory}/benchmarks/database</jub.db.file>
+ <jub.xml.file>${project.build.directory}/benchmarks.xml</jub.xml.file>
+ <jub.charts.dir>${project.build.directory}/site</jub.charts.dir>
+ </systemPropertyVariables>
+ <argLine>-Xmx512m -Xms512m</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
Added: commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmark.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmark.java?rev=1241008&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmark.java (added)
+++ commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmark.java Mon Feb 6 13:46:22 2012
@@ -0,0 +1,108 @@
+package org.apache.commons.graph.spanning;
+
+/*
+ * 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.
+ */
+
+import static java.lang.String.format;
+import static java.lang.String.valueOf;
+import static org.apache.commons.graph.CommonsGraph.minimumSpanningTree;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.graph.GraphException;
+import org.apache.commons.graph.SpanningTree;
+import org.apache.commons.graph.model.BaseLabeledVertex;
+import org.apache.commons.graph.model.BaseLabeledWeightedEdge;
+import org.apache.commons.graph.model.UndirectedMutableWeightedGraph;
+import org.apache.commons.graph.weight.primitive.DoubleWeight;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+
+import com.carrotsearch.junitbenchmarks.BenchmarkRule;
+
+public final class MinimumSpanningTreeBenchmark
+{
+
+ @Rule
+ public BenchmarkRule benchmarkRun = new BenchmarkRule();
+
+ private static final UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> G
+ = new UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double>();
+
+ @BeforeClass
+ public static void setUp()
+ {
+ for ( int i = 0; i < 1000; i++ )
+ {
+ BaseLabeledVertex v = new BaseLabeledVertex( valueOf( i ) );
+ G.addVertex( v );
+ }
+
+ for ( BaseLabeledVertex v1 : G.getVertices() )
+ {
+ int cnt = 0;
+ for ( BaseLabeledVertex v2 : G.getVertices() )
+ {
+ if (cnt++ > 20)
+ {
+ break;
+ }
+ if ( !v1.equals( v2 ) )
+ {
+ try
+ {
+ G.addEdge( v1, new BaseLabeledWeightedEdge<Double>( format( "%s -> %s", v1, v2 ), 7D ), v2 );
+ }
+ catch ( GraphException e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+
+ @Test
+ public void performBoruvka()
+ {
+ SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> actual =
+ minimumSpanningTree( G ).fromArbitrarySource().applyingBoruvkaAlgorithm( new DoubleWeight() );
+
+ assertTrue( actual.getSize() > 0 );
+ }
+
+ @Test
+ public void performKruskal()
+ {
+ SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> actual =
+ minimumSpanningTree( G ).fromArbitrarySource().applyingKruskalAlgorithm( new DoubleWeight() );
+
+ assertTrue( actual.getSize() > 0 );
+ }
+
+ @Test
+ public void performPrim()
+ {
+ SpanningTree<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> actual =
+ minimumSpanningTree( G ).fromArbitrarySource().applyingPrimAlgorithm( new DoubleWeight() );
+
+ assertTrue( actual.getSize() > 0 );
+ }
+
+}
Propchange: commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmark.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmark.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/graph/trunk/src/benchmarks/java/org/apache/commons/graph/spanning/MinimumSpanningTreeBenchmark.java
------------------------------------------------------------------------------
svn:mime-type = text/plain