51Degrees IP Intelligence Go  4.4

IP Intelligence services for 51Degrees Pipeline

examples/onpremise/performance.go

The example illustrates a "clock-time" benchmark for assessing detection speed.

It's important to understand the trade-offs between performance, memory usage and accuracy, that the 51Degrees pipeline configuration makes available, and this example shows a range of different configurations to illustrate the difference in performance.

By default, this example runs in multi-threaded mode using all available CPU cores for optimal performance. Use the --single flag to run in single-threaded mode for comparison.

Requesting properties from a single component reduces detection time compared with requesting properties from multiple components. If you don't specify any properties to detect, then all properties are detected.

This example is available in full on GitHub.

## Usage

# Multi-threaded mode (default)
go run .
# Single-threaded mode
go run . --single

In detail, the example shows how to

1. Specify config for engine:

This setting specifies the performance profile that will be used when initializing the C library.

config := ipi_interop.NewConfigIpi(ipi_interop.InMemory)


2. Initialization of the engine with the following parameters:

engine, err := ipi_onpremise.New(
// Optimized config provided
ipi_onpremise.WithConfigIpi(config),
// Path to your data file
ipi_onpremise.WithDataFile(params.DataFile),
// Enable automatic updates.
ipi_onpremise.WithAutoUpdate(false),
// Set only 1 parameter for getting data
ipi_onpremise.WithProperties([]string{"RegisteredName"}),
)


WithConfigIpi allows to configure the Ipi matching algorithm.

ipi_onpremise.WithConfigIpi(config)


WithDataFile sets the path to the local data file, this parameter is required to start the engine

ipi_onpremise.WithDataFile(params.DataFile),


WithAutoUpdate enables or disables auto update

ipi_onpremise.WithAutoUpdate(false),


WithProperties configures an Engine with a comma-separated list of manager properties derived from the provided slice.te

ipi_onpremise.WithProperties([]string{"RegisteredName"}),


3. Run evidence processing with parameters and get the report as returned value

report, err := runPerformance(engine, params)


Expected output (performance_report.log):

Multi-threaded mode (default):

Average 0.00075 ms per Evidence Record
Average 1333333.33 detections per second
Total Evidence Records: 20000
Iteration Count: 1
Processed Evidence Records: 120000
Number of CPUs: 12

Single-threaded mode (–single flag):

Average 0.00202 ms per Evidence Record
Average 495867.77 detections per second
Total Evidence Records: 20000
Iteration Count: 1
Processed Evidence Records: 120000
Number of CPUs: 12