fiftyone.device.example.illustration
Class Benchmark

java.lang.Object
  extended by fiftyone.device.example.illustration.Benchmark

public class Benchmark
extends Object

Example of a Benchmarking tool using 51Degrees Pattern detection to stress test your system.

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.

  1. Getting the detection time per thread
      
          long start = System.nanoTime();
          bm.provider.match(userAgentString, match);
          bm.elapsedNano.addAndGet(
              System.nanoTime() - start);
      
      
  2. Getting properties to put more stress on the system
      
          bm.provider.dataSet.getProperties()) {
          Values values = match.getValues(property);
          if (values != null) {
              workerCheckSum += values.toStringArray().length;
          } *  
      
You can run main(java.lang.String[]) to test the performance of your system.


Constructor Summary
Benchmark(String userAgentFile)
          Initialises the device detection Provider with the included Lite data file.
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Benchmark

public Benchmark(String userAgentFile)
          throws IOException,
                 IllegalArgumentException
Initialises the device detection Provider with the included Lite data file. For more data see: compare data options

Parameters:
userAgentFile -
Throws:
IOException - if there was a problem reading from the data file.
IllegalArgumentException
Method Detail

getAverageDetectionTimePerThread

public double getAverageDetectionTimePerThread()

getCount

public int getCount()

run

public void run(Dataset dataSet,
                int numberOfThreads)
         throws IOException,
                InterruptedException
Reads a CSV file containing User-Agents performing detection on each one using the provider.

Parameters:
dataSet - to be used for the benchmark.
numberOfThreads -
Throws:
IOException - if there was a problem reading from the data file.
InterruptedException

fileAsBytes

protected static byte[] fileAsBytes(String deviceDataFile)
                             throws IOException
Throws:
IOException

main

public static void main(String[] args)
                 throws IOException,
                        InterruptedException
Instantiates this class and starts runBenchmarks(String, String, int) with parameters from the command line.

Parameters:
args - command line arguments.
Throws:
IOException
InterruptedException


Copyright © 2017 51Degrees. All rights reserved.