Differential D7890 Diff 28929 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.SwhBidirectionalGraph; | 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 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 { | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | public static void main(String[] args) { | ||||
} | } | ||||
if (node == null || node == END_OF_QUEUE) { | if (node == null || node == END_OF_QUEUE) { | ||||
return; | return; | ||||
} | } | ||||
Traversal t = new Traversal(thread_graph, "backward", edgesFmt); | Traversal t = new Traversal(thread_graph, "backward", edgesFmt); | ||||
int[] count = {0}; | int[] count = {0}; | ||||
startTime = Timing.start(); | startTime = System.nanoTime(); | ||||
t.visitNodesVisitor(node, (curnode) -> { | t.visitNodesVisitor(node, (curnode) -> { | ||||
if (tp.graph.getNodeType(curnode) == dstType) { | if (tp.graph.getNodeType(curnode) == dstType) { | ||||
count[0]++; | count[0]++; | ||||
} | } | ||||
}); | }); | ||||
totalTime = Timing.stop(startTime); | long endTime = System.nanoTime(); | ||||
totalTime = (double) (endTime - startTime) / 1e9; | |||||
System.out.format("%d %d %d %d %f\n", node, count[0], t.getNbNodesAccessed(), | System.out.format("%d %d %d %d %f\n", node, count[0], t.getNbNodesAccessed(), | ||||
t.getNbEdgesAccessed(), totalTime); | t.getNbEdgesAccessed(), totalTime); | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
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 = SwhBidirectionalGraph.loadMapped(graphBasename); | this.graph = SwhBidirectionalGraph.loadMapped(graphBasename); | ||||
System.err.println("Graph loaded."); | System.err.println("Graph loaded."); | ||||
} | } | ||||
} | } |