summaryrefslogtreecommitdiffstats
path: root/it/jvpp-benchmark/src/main/java
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2018-05-24 10:49:51 +0200
committerMarek Gradzki <mgradzki@cisco.com>2018-05-24 09:49:33 +0000
commitaf45924fb4aa8a73c8be2f4f7bcf1847dee46574 (patch)
tree7c1b0ef087af0fb8d5e0c0a8539656a79bf46815 /it/jvpp-benchmark/src/main/java
parentd3cc46c357c83c0c0b41b4f64b166bbb40b74743 (diff)
jvpp-benchmark: fix IP generation
Change-Id: I5ab4465f25c13e0f3b89e2757bde9dd47c660732 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'it/jvpp-benchmark/src/main/java')
-rw-r--r--it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclProviderImpl.java34
-rw-r--r--it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclUpdateBenchmark.java2
2 files changed, 21 insertions, 15 deletions
diff --git a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclProviderImpl.java b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclProviderImpl.java
index 4a39becad..fea9055ea 100644
--- a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclProviderImpl.java
+++ b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclProviderImpl.java
@@ -27,6 +27,7 @@ class AclProviderImpl implements AclProvider {
private final int aclSetSize;
private final AclAddReplace[] acls;
+ private final IpProvider ipProvider = new IpProvider();
/**
* Pointer to ACL to be returned by invocation of {@link #next()} method.
@@ -54,29 +55,28 @@ class AclProviderImpl implements AclProvider {
}
private void initAcls(final int aclSetSize, final int aclSize) {
- long ip = 0x01000000; // 1.0.0.0
for (int i = 0; i < aclSetSize; ++i) {
- acls[i] = createAddReplaceRequest(aclSize, CREATE_NEW_ACL, (int) (ip++));
+ acls[i] = createAddReplaceRequest(aclSize, CREATE_NEW_ACL);
}
}
- private static AclAddReplace createAddReplaceRequest(final int size, final int index, final int ip) {
+ private AclAddReplace createAddReplaceRequest(final int size, final int index) {
AclAddReplace request = new AclAddReplace();
request.aclIndex = index;
request.count = size;
- request.r = createRules(size, ip);
+ request.r = createRules(size);
return request;
}
- private static AclRule[] createRules(final int size, final int ip) {
+ private AclRule[] createRules(final int size) {
final AclRule[] rules = new AclRule[size];
for (int i = 0; i < size; ++i) {
rules[i] = new AclRule();
rules[i].isIpv6 = 0;
rules[i].isPermit = 1;
- rules[i].srcIpAddr = getIp(ip);
+ rules[i].srcIpAddr = ipProvider.next();
rules[i].srcIpPrefixLen = 32;
- rules[i].dstIpAddr = getIp(ip);
+ rules[i].dstIpAddr = ipProvider.next();
rules[i].dstIpPrefixLen = 32;
rules[i].dstportOrIcmpcodeFirst = 0;
rules[i].dstportOrIcmpcodeLast = MAX_PORT_NUMBER;
@@ -87,11 +87,19 @@ class AclProviderImpl implements AclProvider {
return rules;
}
- private static byte[] getIp(final int i) {
- int b1 = (i >> 24) & 0xff;
- int b2 = (i >> 16) & 0xff;
- int b3 = (i >> 8) & 0xff;
- int b4 = i & 0xff;
- return new byte[] {(byte) b1, (byte) b2, (byte) b3, (byte) b4};
+ private static final class IpProvider {
+ private long ip = 0x01000000; // 1.0.0.0
+
+ private static byte[] getIp(final int i) {
+ int b1 = (i >> 24) & 0xff;
+ int b2 = (i >> 16) & 0xff;
+ int b3 = (i >> 8) & 0xff;
+ int b4 = i & 0xff;
+ return new byte[] {(byte) b1, (byte) b2, (byte) b3, (byte) b4};
+ }
+
+ private byte[] next() {
+ return getIp((int) (ip++));
+ }
}
} \ No newline at end of file
diff --git a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclUpdateBenchmark.java b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclUpdateBenchmark.java
index 8a26e2d21..ef314b8e5 100644
--- a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclUpdateBenchmark.java
+++ b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/AclUpdateBenchmark.java
@@ -16,8 +16,6 @@
package io.fd.hc2vpp.it.jvpp.benchmark;
-import static org.openjdk.jmh.annotations.Mode.Throughput;
-
import com.google.common.io.CharStreams;
import io.fd.vpp.jvpp.JVppRegistryImpl;
import io.fd.vpp.jvpp.acl.JVppAclImpl;