title

Calculating Detection Speed

Engineering

11/25/2014 9:49 AM

Device Detection Performance C Development

How do we know each detection only takes 0.0016ms?

Earlier this year we published a blog post called "why fast device detection matters". Amongst other things this blog contained test descriptions and results for 3 different, moderately-priced platforms. For each test case a table was created to show how device detection performed with the given number of threads on that particular hardware platform. The focus of the article was to demonstrate the amount of detection you can potentially get on low-end server and consumer equivalent hardware.

The blog post has now been updated to describe how we measure detection time for a single device, and hence how we got the number of 0.0016ms. Essentially what we did was: run the test with one thread and divide one second by the average number of detections we obtained during that test. You can easily reproduce this test on any platform with GCC, just follow the guide below. The following tutorial assumes some familiarity with GCC and source code editing.

DIY

1: Download our C distribution from sourceforge. Unpack the archive.

Arrow pointing towards the next step.

2: For our test we will be using Trie. You will need to make the following modifications to achieve the best performance on your system. In 'src/trie/PerfTrie.c' change the THREAD_COUNT value as follows:

Arrow pointing towards the next step.

- If you want to measure how many detections per second your system can achieve, set THREAD_COUNT equal to the number of virtual CPU cores available on your system. I.e. for 4-core CPU with 8 virtual cores the ideal THREAD_COUNT is 8.

- If you want to measure the detection time for a single device, then set THREAD_COUNT to 1. You will then need to divide 1000 milliseconds (1 second) by the average number of detections you get after running this test.

Arrow pointing towards the next step.

Make sure that makefile has -O3 optimization level enabled. The result is likely to be very different without -O3 directive.

Arrow pointing towards the next step.

3: Now run the relevant build file (on Windows) or use the terminal to compile with makefile on UNIX (makefile can also be used on Windows if you have GCC installed).

Arrow pointing towards the next step.

4: Once compilation is complete you will see 4-5 programs in the root folder of 51Degrees C distribution. Execute PerfTrie as follows:

PerfTrie.exe TrieDataFile UserAgentsFile [Properties]

Where:

- TrieDataFile is the path to 51Degrees Trie device data file. A Lite version of this file is supplied with the detector.

- UserAgentsFile is a path to file containing user agents to be matched.

- [Properties] is a comma-separated list with device properties you want to be returned. Device Id is used if no Properties are selected.

Not yet a 51Degrees user? In that case compare us against your current tool, you may be surprised by the results. Other solutions on the market may claim to be the fastest, most accurate or both, so why not test that out for yourselves rather than rely on unproven claims?

External Resources

Photo "Plugged" by Keoni Cabral, modified by 51Degrees, is licensed under CC BY 2.0