Differential D6953 Diff 25202 java/src/main/java/org/softwareheritage/graph/experiments/multiplicationfactor/GenDistribution.java
Changeset View
Changeset View
Standalone View
Standalone View
java/src/main/java/org/softwareheritage/graph/experiments/multiplicationfactor/GenDistribution.java
package org.softwareheritage.graph.experiments.multiplicationfactor; | package org.softwareheritage.graph.experiments.multiplicationfactor; | ||||
import com.martiansoftware.jsap.*; | import com.martiansoftware.jsap.*; | ||||
import org.softwareheritage.graph.Graph; | import org.softwareheritage.graph.SwhBidirectionalGraph; | ||||
import org.softwareheritage.graph.Node; | import org.softwareheritage.graph.Node; | ||||
import org.softwareheritage.graph.Traversal; | import org.softwareheritage.graph.Traversal; | ||||
import org.softwareheritage.graph.benchmark.utils.Timing; | import org.softwareheritage.graph.benchmark.utils.Timing; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.Scanner; | import java.util.Scanner; | ||||
import java.util.concurrent.ArrayBlockingQueue; | import java.util.concurrent.ArrayBlockingQueue; | ||||
import java.util.concurrent.ExecutorService; | import java.util.concurrent.ExecutorService; | ||||
import java.util.concurrent.Executors; | import java.util.concurrent.Executors; | ||||
public class GenDistribution { | public class GenDistribution { | ||||
private Graph graph; | private SwhBidirectionalGraph graph; | ||||
private static JSAPResult parse_args(String[] args) { | private static JSAPResult parse_args(String[] args) { | ||||
JSAPResult config = null; | JSAPResult config = null; | ||||
try { | try { | ||||
SimpleJSAP jsap = new SimpleJSAP(GenDistribution.class.getName(), "", | SimpleJSAP jsap = new SimpleJSAP(GenDistribution.class.getName(), "", | ||||
new Parameter[]{ | new Parameter[]{ | ||||
new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g', | new FlaggedOption("graphPath", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g', | ||||
"graph", "Basename of the compressed graph"), | "graph", "Basename of the compressed graph"), | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | public static void main(String[] args) { | ||||
e.printStackTrace(); | e.printStackTrace(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
}); | }); | ||||
for (int i = 0; i < numThreads; ++i) { | for (int i = 0; i < numThreads; ++i) { | ||||
service.submit(() -> { | service.submit(() -> { | ||||
Graph thread_graph = tp.graph.copy(); | SwhBidirectionalGraph thread_graph = tp.graph.copy(); | ||||
long startTime; | long startTime; | ||||
double totalTime; | double totalTime; | ||||
while (true) { | while (true) { | ||||
Long node = null; | Long node = null; | ||||
try { | try { | ||||
node = queue.take(); | node = queue.take(); | ||||
} catch (InterruptedException e) { | } catch (InterruptedException e) { | ||||
Show All 19 Lines | public static void main(String[] args) { | ||||
}); | }); | ||||
} | } | ||||
service.shutdown(); | service.shutdown(); | ||||
} | } | ||||
private void load_graph(String graphBasename) throws IOException { | private void load_graph(String graphBasename) throws IOException { | ||||
System.err.println("Loading graph " + graphBasename + " ..."); | System.err.println("Loading graph " + graphBasename + " ..."); | ||||
this.graph = Graph.loadMapped(graphBasename); | this.graph = SwhBidirectionalGraph.loadMapped(graphBasename); | ||||
System.err.println("Graph loaded."); | System.err.println("Graph loaded."); | ||||
} | } | ||||
} | } |