Differential D6953 Diff 25202 java/src/main/java/org/softwareheritage/graph/benchmark/Benchmark.java
Changeset View
Changeset View
Standalone View
Standalone View
java/src/main/java/org/softwareheritage/graph/benchmark/Benchmark.java
package org.softwareheritage.graph.benchmark; | package org.softwareheritage.graph.benchmark; | ||||
import com.martiansoftware.jsap.*; | import com.martiansoftware.jsap.*; | ||||
import org.softwareheritage.graph.Graph; | import org.softwareheritage.graph.SwhBidirectionalGraph; | ||||
import org.softwareheritage.graph.SWHID; | import org.softwareheritage.graph.SWHID; | ||||
import org.softwareheritage.graph.benchmark.utils.Random; | import org.softwareheritage.graph.benchmark.utils.Random; | ||||
import org.softwareheritage.graph.benchmark.utils.Statistics; | import org.softwareheritage.graph.benchmark.utils.Statistics; | ||||
import org.softwareheritage.graph.server.Endpoint; | import org.softwareheritage.graph.server.Endpoint; | ||||
import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
import java.io.FileWriter; | import java.io.FileWriter; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | public class Benchmark { | ||||
* @param useCaseName benchmark use-case name | * @param useCaseName benchmark use-case name | ||||
* @param graph compressed graph used in the benchmark | * @param graph compressed graph used in the benchmark | ||||
* @param nodeIds node ids to use as starting point for the endpoint traversal | * @param nodeIds node ids to use as starting point for the endpoint traversal | ||||
* @param operation endpoint function to benchmark | * @param operation endpoint function to benchmark | ||||
* @param dstFmt destination formatted string as described in the | * @param dstFmt destination formatted string as described in the | ||||
* <a href="https://docs.softwareheritage.org/devel/swh-graph/api.html#walk">API</a> | * <a href="https://docs.softwareheritage.org/devel/swh-graph/api.html#walk">API</a> | ||||
* @param algorithm traversal algorithm used in endpoint call (either "dfs" or "bfs") | * @param algorithm traversal algorithm used in endpoint call (either "dfs" or "bfs") | ||||
*/ | */ | ||||
public void timeEndpoint(String useCaseName, Graph graph, long[] nodeIds, | public void timeEndpoint(String useCaseName, SwhBidirectionalGraph graph, long[] nodeIds, | ||||
Function<Endpoint.Input, Endpoint.Output> operation, String dstFmt, String algorithm) throws IOException { | Function<Endpoint.Input, Endpoint.Output> operation, String dstFmt, String algorithm) throws IOException { | ||||
ArrayList<Double> timings = new ArrayList<>(); | ArrayList<Double> timings = new ArrayList<>(); | ||||
ArrayList<Double> timingsNormalized = new ArrayList<>(); | ArrayList<Double> timingsNormalized = new ArrayList<>(); | ||||
ArrayList<Double> nbEdgesAccessed = new ArrayList<>(); | ArrayList<Double> nbEdgesAccessed = new ArrayList<>(); | ||||
final boolean append = true; | final boolean append = true; | ||||
try (Writer csvLog = new BufferedWriter(new FileWriter(args.logFile, append))) { | try (Writer csvLog = new BufferedWriter(new FileWriter(args.logFile, append))) { | ||||
for (long nodeId : nodeIds) { | for (long nodeId : nodeIds) { | ||||
Show All 31 Lines | public void timeEndpoint(String useCaseName, SwhBidirectionalGraph graph, long[] nodeIds, | ||||
System.out.println("nb edges accessed:"); | System.out.println("nb edges accessed:"); | ||||
Statistics statsNbEdgesAccessed = new Statistics(nbEdgesAccessed); | Statistics statsNbEdgesAccessed = new Statistics(nbEdgesAccessed); | ||||
statsNbEdgesAccessed.printAll(); | statsNbEdgesAccessed.printAll(); | ||||
} | } | ||||
/** | /** | ||||
* Same as {@link #timeEndpoint} but without destination or algorithm specified to endpoint call. | * Same as {@link #timeEndpoint} but without destination or algorithm specified to endpoint call. | ||||
*/ | */ | ||||
public void timeEndpoint(String useCaseName, Graph graph, long[] nodeIds, | public void timeEndpoint(String useCaseName, SwhBidirectionalGraph graph, long[] nodeIds, | ||||
Function<Endpoint.Input, Endpoint.Output> operation) throws IOException { | Function<Endpoint.Input, Endpoint.Output> operation) throws IOException { | ||||
timeEndpoint(useCaseName, graph, nodeIds, operation, null, null); | timeEndpoint(useCaseName, graph, nodeIds, operation, null, null); | ||||
} | } | ||||
/** | /** | ||||
* Input arguments. | * Input arguments. | ||||
*/ | */ | ||||
public class Args { | public class Args { | ||||
Show All 10 Lines |