Differential D6953 Diff 25202 java/src/main/java/org/softwareheritage/graph/benchmark/AccessEdge.java
Changeset View
Changeset View
Standalone View
Standalone View
java/src/main/java/org/softwareheritage/graph/benchmark/AccessEdge.java
package org.softwareheritage.graph.benchmark; | package org.softwareheritage.graph.benchmark; | ||||
import com.martiansoftware.jsap.JSAPException; | import com.martiansoftware.jsap.JSAPException; | ||||
import it.unimi.dsi.big.webgraph.LazyLongIterator; | import it.unimi.dsi.big.webgraph.LazyLongIterator; | ||||
import org.softwareheritage.graph.Graph; | import org.softwareheritage.graph.SwhBidirectionalGraph; | ||||
import org.softwareheritage.graph.benchmark.utils.Statistics; | import org.softwareheritage.graph.benchmark.utils.Statistics; | ||||
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.ArrayList; | import java.util.ArrayList; | ||||
/** | /** | ||||
* Benchmark to time edge access time. | * Benchmark to time edge access time. | ||||
* | * | ||||
* @author The Software Heritage developers | * @author The Software Heritage developers | ||||
*/ | */ | ||||
public class AccessEdge { | public class AccessEdge { | ||||
/** | /** | ||||
* Main entrypoint. | * Main entrypoint. | ||||
* | * | ||||
* @param args command line arguments | * @param args command line arguments | ||||
*/ | */ | ||||
public static void main(String[] args) throws IOException, JSAPException { | public static void main(String[] args) throws IOException, JSAPException { | ||||
Benchmark bench = new Benchmark(); | Benchmark bench = new Benchmark(); | ||||
bench.parseCommandLineArgs(args); | bench.parseCommandLineArgs(args); | ||||
Graph graph = Graph.loadMapped(bench.args.graphPath); | SwhBidirectionalGraph graph = SwhBidirectionalGraph.loadMapped(bench.args.graphPath); | ||||
long[] nodeIds = bench.args.random.generateNodeIds(graph, bench.args.nbNodes); | long[] nodeIds = bench.args.random.generateNodeIds(graph, bench.args.nbNodes); | ||||
ArrayList<Double> timings = new ArrayList<>(); | ArrayList<Double> timings = new ArrayList<>(); | ||||
for (long nodeId : nodeIds) { | for (long nodeId : nodeIds) { | ||||
long startTime = Timing.start(); | long startTime = Timing.start(); | ||||
LazyLongIterator neighbors = graph.successors(nodeId); | LazyLongIterator neighbors = graph.successors(nodeId); | ||||
long firstNeighbor = neighbors.nextLong(); | long firstNeighbor = neighbors.nextLong(); | ||||
Show All 9 Lines |