Skip to content

Commit

Permalink
benchmarks: add benchmark for ip address matcher
Browse files Browse the repository at this point in the history
Motivation:
 - Benchmark IP matcher that used for processed of any NFS request.
 - enhancing JMH knowledge

Modification:
Add benchmark for ip address matcher.

Result:

Benchmark                                      (client)                 (template)   Mode  Cnt          Score         Error  Units
IpMatcherBenchmark.benchmark                192.168.1.1                192.168.1.1  thrpt   25  156536643.166 ± 3114973.363  ops/s
IpMatcherBenchmark.benchmark                192.168.1.1             192.168.1.0/24  thrpt   25  154687994.062 ± 5716679.866  ops/s
IpMatcherBenchmark.benchmark                192.168.1.1  fe80::9cef:10f5:f2ae:1aa1  thrpt   25  269111251.883 ± 6734146.251  ops/s
IpMatcherBenchmark.benchmark                192.168.5.1                192.168.1.1  thrpt   25  158110904.503 ± 1620381.437  ops/s
IpMatcherBenchmark.benchmark                192.168.5.1             192.168.1.0/24  thrpt   25  158561449.487 ± 1235704.889  ops/s
IpMatcherBenchmark.benchmark                192.168.5.1  fe80::9cef:10f5:f2ae:1aa1  thrpt   25  268281161.960 ± 7108881.055  ops/s
IpMatcherBenchmark.benchmark  fe80::9cef:10f5:f2ae:1aa1                192.168.1.1  thrpt   25   89801555.808 ± 2076211.604  ops/s
IpMatcherBenchmark.benchmark  fe80::9cef:10f5:f2ae:1aa1             192.168.1.0/24  thrpt   25   83486786.674 ± 2644654.536  ops/s
IpMatcherBenchmark.benchmark  fe80::9cef:10f5:f2ae:1aa1  fe80::9cef:10f5:f2ae:1aa1  thrpt   25   41586454.663 ± 1515126.298  ops/s

Acked-by: Paul Millar
Target: master
  • Loading branch information
kofemann committed Apr 24, 2019
1 parent d541ec6 commit 5712ae6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class BenchmarkRunner {
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(ConcurrentLockManagerBenchmark.class.getSimpleName())
.include(IpMatcherBenchmark.class.getSimpleName())
.resultFormat(ResultFormatType.JSON)
.build();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.dcache.nfs.benchmarks;

import com.google.common.net.InetAddresses;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.dcache.nfs.InetAddressMatcher;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;

/**
*
*/
@State(Scope.Thread)
@BenchmarkMode(Mode.Throughput)
public class IpMatcherBenchmark {

private InetAddressMatcher addressMatcher;
private InetAddress address;

@Param({"192.168.1.1", "192.168.1.0/24", "fe80::9cef:10f5:f2ae:1aa1", "fe80::9cef:10f5:f2ae:1aa1/48"})
private String template;

@Param({"192.168.1.1", "192.168.5.1", "fe80::9cef:10f5:f2ae:1aa1", "fe80:cd00:0:cde:1257:0:211e:729c"})
private String client;

@Setup
public void setUp() throws UnknownHostException {
addressMatcher = InetAddressMatcher.forPattern(template);
address = InetAddresses.forString(client);
}

@Benchmark
public boolean benchmark() {
return addressMatcher.match(address);
}

}

0 comments on commit 5712ae6

Please sign in to comment.