public class Benchmark extends Object
The Example takes three arguments in the form of the 51Degrees binary device data file path, the path of a .csv file containing User-Agents to be matched and the number of threads you want to use for detection (optional where the default is the number or logical cores in your current system. The Example tests three different memory profiles: stream memory, stream file and memory modes.
long start = System.nanoTime();
bm.provider.match(userAgentString, match);
bm.elapsedNano.addAndGet(
System.nanoTime() - start);
bm.provider.dataSet.getProperties()) {
Values values = match.getValues(property);
if (values != null) {
workerCheckSum += values.toStringArray().length;
} *
main(java.lang.String[]) to test the performance of your system.
| Constructor and Description |
|---|
Benchmark(String userAgentFile)
Initialises the device detection Provider with the included Lite data
file.
|
| Modifier and Type | Method and Description |
|---|---|
protected static byte[] |
fileAsBytes(String deviceDataFile) |
double |
getAverageDetectionTimePerThread() |
int |
getCount() |
static void |
main(String[] args)
Instantiates this class and starts
runBenchmarks(String, String, int) with parameters from the
command line. |
void |
run(Dataset dataSet,
int numberOfThreads)
Reads a CSV file containing User-Agents performing detection on each
one using the provider.
|
public Benchmark(String userAgentFile) throws IOException, IllegalArgumentException
userAgentFile - path to the source User-Agents file.IOException - if there was a problem reading from the data file.IllegalArgumentExceptionpublic double getAverageDetectionTimePerThread()
public int getCount()
public void run(Dataset dataSet, int numberOfThreads) throws IOException, InterruptedException
dataSet - to be used for the benchmark.numberOfThreads - IOException - if there was a problem reading from the data file.InterruptedException - if one of the benchmark threads is interrupted.protected static byte[] fileAsBytes(String deviceDataFile) throws IOException
IOExceptionpublic static void main(String[] args) throws IOException, InterruptedException
runBenchmarks(String, String, int) with parameters from the
command line.args - command line arguments.IOException - if the data file cannot be accessed.InterruptedException - if the benchmark threads are interrupted.Copyright © 2018 51Degrees. All rights reserved.