changeset 604:4cbc75e90f7e

stress-tester-benchmark - changed dependency com.passus.tester:stress-tester -> com.passus.st:stress-tester
author Devel 1
date Fri, 06 Oct 2017 10:42:04 +0200
parents c70bc3304737
children 5c0b5bfd2972
files stress-tester-benchmark/pom.xml stress-tester-benchmark/src/main/java/com/passus/compress/Decompression.java stress-tester-benchmark/src/main/java/com/passus/data/ByteBufferBenchmark.java stress-tester-benchmark/src/main/java/com/passus/data/ByteStringBenchmark_Equals.java stress-tester-benchmark/src/main/java/com/passus/data/ByteStringBuilderBenchmark.java stress-tester-benchmark/src/main/java/com/passus/dissector/Dissector.java stress-tester-benchmark/src/main/java/com/passus/http/HttpUtilsBenchmark.java stress-tester-benchmark/src/main/java/com/passus/net/http/CookieDate.java stress-tester-benchmark/src/main/java/com/passus/net/http/HttpCookieDecoderBenchmark.java stress-tester-benchmark/src/main/java/com/passus/net/http/HttpCookieDecoderBennchmark.java stress-tester-benchmark/src/main/java/com/passus/net/http/HttpDigestMD5Benchmark.java stress-tester-benchmark/src/main/java/com/passus/net/http/HttpRequestDecodingBenchmark.java stress-tester-benchmark/src/main/java/com/passus/net/http/UrlBenchmark.java stress-tester-benchmark/src/main/java/com/passus/packetcounter/PacketCounter.java stress-tester-benchmark/src/main/java/com/passus/st/client/http/filter/HttpMessagePredicateBenchmark.java stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/CookieDate.java stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/HttpCookieDecoderBenchmark.java stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/HttpCookieDecoderBennchmark.java stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/HttpDigestMD5Benchmark.java stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/HttpRequestDecodingBenchmark.java stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/UrlBenchmark.java stress-tester-benchmark/src/main/java/com/passus/st/utils/MultiByteUtilsBenchmark.java
diffstat 22 files changed, 827 insertions(+), 799 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester-benchmark/pom.xml	Fri Oct 06 10:03:29 2017 +0200
+++ b/stress-tester-benchmark/pom.xml	Fri Oct 06 10:42:04 2017 +0200
@@ -59,6 +59,12 @@
         </dependency>
 
         <dependency>
+            <groupId>com.passus.st</groupId>
+            <artifactId>stress-tester</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
             <groupId>log4j</groupId>
             <artifactId>log4j</artifactId>
             <version>1.2.17</version>
@@ -83,24 +89,6 @@
         </dependency>
 
         <dependency>
-            <groupId>com.passus.tester</groupId>
-            <artifactId>stress-tester</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>*</groupId>
-                    <artifactId>*</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-
-        <dependency>
-            <groupId>com.passus.st</groupId>
-            <artifactId>stress-tester-reporter</artifactId>
-            <version>1.0-SNAPSHOT</version>
-        </dependency>
-
-        <dependency>
             <groupId>com.esotericsoftware</groupId>
             <artifactId>kryo</artifactId>
             <version>4.0.0</version>
--- a/stress-tester-benchmark/src/main/java/com/passus/compress/Decompression.java	Fri Oct 06 10:03:29 2017 +0200
+++ b/stress-tester-benchmark/src/main/java/com/passus/compress/Decompression.java	Fri Oct 06 10:42:04 2017 +0200
@@ -1,9 +1,9 @@
 package com.passus.compress;
 
 import com.passus.ambience.utils.TestResourceUtils;
-import com.passus.st.compression.GZIPDecompressionProcessor;
-import com.passus.st.compression.InflaterProcessor;
-import com.passus.st.data.HeapByteBuffer;
+import com.passus.data.HeapByteBuff;
+import com.passus.data.compression.GZIPDecompressionProcessor;
+import com.passus.data.compression.InflaterProcessor;
 import com.passus.utils.AllocationUtils;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -64,7 +64,7 @@
     public int deflateStream() throws IOException {
         ByteArrayInputStream bais = new ByteArrayInputStream(DEFLATE_BYTES);
         InflaterInputStream is = new InflaterInputStream(bais, new Inflater(true), compBufferSize);
-        HeapByteBuffer out = new HeapByteBuffer(DEFLATE_BYTES.length);
+        HeapByteBuff out = new HeapByteBuff(DEFLATE_BYTES.length);
         int b;
         while ((b = is.read(intermediateBuffer)) != -1) {
             out.append(intermediateBuffer, 0, b);
@@ -75,7 +75,7 @@
     @Benchmark
     public int deflateProcessor() {
         InflaterProcessor proc = new InflaterProcessor(true);
-        HeapByteBuffer out = new HeapByteBuffer(DEFLATE_BYTES.length);
+        HeapByteBuff out = new HeapByteBuff(DEFLATE_BYTES.length);
         proc.process(DEFLATE_BYTES, out);
         return out.length();
     }
@@ -84,7 +84,7 @@
     public int gzipStream() throws IOException {
         ByteArrayInputStream bais = new ByteArrayInputStream(GZIP_BYTES);
         GZIPInputStream is = new GZIPInputStream(bais, compBufferSize);
-        HeapByteBuffer out = new HeapByteBuffer(GZIP_BYTES.length);
+        HeapByteBuff out = new HeapByteBuff(GZIP_BYTES.length);
         int b;
         while ((b = is.read(intermediateBuffer)) != -1) {
             out.append(intermediateBuffer, 0, b);
@@ -95,7 +95,7 @@
     @Benchmark
     public int gzipProcessor() {
         GZIPDecompressionProcessor proc = new GZIPDecompressionProcessor();
-        HeapByteBuffer out = new HeapByteBuffer(GZIP_BYTES.length);
+        HeapByteBuff out = new HeapByteBuff(GZIP_BYTES.length);
         proc.process(GZIP_BYTES, out);
         return out.length();
     }
@@ -104,7 +104,7 @@
     public int brotliStream() throws IOException {
         ByteArrayInputStream bais = new ByteArrayInputStream(BROTLI_BYTES);
         org.brotli.dec.BrotliInputStream is = new BrotliInputStream(bais);
-        HeapByteBuffer out = new HeapByteBuffer(GZIP_BYTES.length);
+        HeapByteBuff out = new HeapByteBuff(GZIP_BYTES.length);
         int b;
         while ((b = is.read(intermediateBuffer)) != -1) {
             out.append(intermediateBuffer, 0, b);
--- a/stress-tester-benchmark/src/main/java/com/passus/data/ByteBufferBenchmark.java	Fri Oct 06 10:03:29 2017 +0200
+++ b/stress-tester-benchmark/src/main/java/com/passus/data/ByteBufferBenchmark.java	Fri Oct 06 10:42:04 2017 +0200
@@ -1,8 +1,6 @@
 package com.passus.data;
 
-import static com.passus.ambience.protocol.http.HttpConsts.DEFAULT_ENCODING;
-import com.passus.st.data.HeapByteBuffer;
-import com.passus.st.utils.AsciiUtils;
+import com.passus.commons.AsciiUtils;
 import java.io.IOException;
 import java.nio.charset.Charset;
 import java.util.concurrent.TimeUnit;
@@ -32,10 +30,10 @@
 @Warmup(iterations = 3)
 public class ByteBufferBenchmark {
 
-    private final HeapByteBuffer buffer = new HeapByteBuffer();
+    private final HeapByteBuff buffer = new HeapByteBuff();
 
-    public static final Charset CHARSET_ISO_8859_1 = Charset.forName(DEFAULT_ENCODING);
-    
+    public static final Charset CHARSET_ISO_8859_1 = Charset.forName("ISO-8859-1");
+
     {
         for (int i = AsciiUtils.SPACE; i < AsciiUtils.DEL; i++) {
             buffer.append(i);
@@ -56,12 +54,12 @@
     public int testToString_CHARSET_ISO_8859_1() {
         return buffer.toString(CHARSET_ISO_8859_1).length();
     }
-    
+
     @Benchmark
     public int testToByteStringAndTrim() {
         return buffer.toByteString().trim().length();
     }
-    
+
     public static void main(String[] args) throws RunnerException, IOException, Exception {
         Options opt = new OptionsBuilder().include(ByteBufferBenchmark.class.getSimpleName() + ".*").build();
         new Runner(opt).run();
--- a/stress-tester-benchmark/src/main/java/com/passus/data/ByteStringBenchmark_Equals.java	Fri Oct 06 10:03:29 2017 +0200
+++ b/stress-tester-benchmark/src/main/java/com/passus/data/ByteStringBenchmark_Equals.java	Fri Oct 06 10:42:04 2017 +0200
@@ -1,6 +1,5 @@
 package com.passus.data;
 
-import com.passus.st.data.ByteStringImpl;
 import java.io.IOException;
 import java.util.concurrent.TimeUnit;
 import org.apache.commons.lang3.StringUtils;
@@ -32,21 +31,17 @@
 
     private int charsNum = 100;
 
-    private String str1 = StringUtils.repeat("a", charsNum);
-
-    private String str2 = StringUtils.repeat("a", charsNum);
-
-    private ByteStringImpl bs1 = new ByteStringImpl(str1);
+    private final String str1 = StringUtils.repeat("a", charsNum);
+    private final String str2 = StringUtils.repeat("a", charsNum);
 
-    private ByteStringImpl bs2 = new ByteStringImpl(str2);
-
-    private char[] chs1 = new char[charsNum];
+    private final ByteStringImpl bs1 = new ByteStringImpl(str1);
+    private final ByteStringImpl bs2 = new ByteStringImpl(str2);
 
-    private char[] chs2 = new char[charsNum];
+    private final char[] chs1 = new char[charsNum];
+    private final char[] chs2 = new char[charsNum];
 
-    private byte[] bytes1 = new byte[charsNum];
-
-    private byte[] bytes2 = new byte[charsNum];
+    private final byte[] bytes1 = new byte[charsNum];
+    private final byte[] bytes2 = new byte[charsNum];
 
     {
         for (int i = 0; i < charsNum; i++) {
--- a/stress-tester-benchmark/src/main/java/com/passus/data/ByteStringBuilderBenchmark.java	Fri Oct 06 10:03:29 2017 +0200
+++ b/stress-tester-benchmark/src/main/java/com/passus/data/ByteStringBuilderBenchmark.java	Fri Oct 06 10:42:04 2017 +0200
@@ -1,6 +1,5 @@
 package com.passus.data;
 
-import com.passus.st.data.ByteStringBuilder;
 import java.io.IOException;
 import java.util.concurrent.TimeUnit;
 import org.apache.commons.lang3.StringUtils;
@@ -34,7 +33,7 @@
     @Param({"10", "500"})
     private int loop = 10;
 
-    private String[] values = new String[500];
+    private final String[] values = new String[500];
 
     {
         for (int i = 0; i < 500; i++) {
--- a/stress-tester-benchmark/src/main/java/com/passus/dissector/Dissector.java	Fri Oct 06 10:03:29 2017 +0200
+++ b/stress-tester-benchmark/src/main/java/com/passus/dissector/Dissector.java	Fri Oct 06 10:42:04 2017 +0200
@@ -1,6 +1,6 @@
 package com.passus.dissector;
 
-import com.passus.st.utils.MultiByteUtils;
+import com.passus.data.DataHelper;
 import java.nio.ByteOrder;
 
 /**
@@ -73,7 +73,7 @@
         }
     }
 
-    static final MultiByteUtils BE = MultiByteUtils.get(ByteOrder.BIG_ENDIAN);
+    static final DataHelper BE = DataHelper.get(ByteOrder.BIG_ENDIAN);
 
     static int decode(Packet p, byte[] b, byte[] out) {
         p.reset();
@@ -84,11 +84,11 @@
         p.layers |= Packet.LAYER_IP;
         p.ip4.srcIp = mkArray(b, 14 + 12, 4);
         p.ip4.dstIp = mkArray(b, 14 + 16, 4);
-        int ipTotalLen = BE.loadS(b, 14 + 2);
+        int ipTotalLen = BE.getShort(b, 14 + 2);
 
         p.layers |= Packet.LAYER_TCP;
-        p.tcp.srcPort = Short.toUnsignedInt(BE.loadS(b, 34));
-        p.tcp.dstPort = Short.toUnsignedInt(BE.loadS(b, 34 + 2));
+        p.tcp.srcPort = Short.toUnsignedInt(BE.getShort(b, 34));
+        p.tcp.dstPort = Short.toUnsignedInt(BE.getShort(b, 34 + 2));
         int tcpLen = (((b[34 + 12]) >> 4) & 0x0f) * 4;
 
         int payloadOff = 34 + tcpLen;
@@ -106,11 +106,11 @@
         p.layers |= Packet.LAYER_IP;
         p.ip4.srcIp = mkArray(b, 14 + 12, 4);
         p.ip4.dstIp = mkArray(b, 14 + 16, 4);
-        int ipTotalLen = BE.loadS(b, 14 + 2);
+        int ipTotalLen = BE.getShort(b, 14 + 2);
 
         p.layers |= Packet.LAYER_TCP;
-        p.tcp.srcPort = Short.toUnsignedInt(BE.loadS(b, 34));
-        p.tcp.dstPort = Short.toUnsignedInt(BE.loadS(b, 34 + 2));
+        p.tcp.srcPort = Short.toUnsignedInt(BE.getShort(b, 34));
+        p.tcp.dstPort = Short.toUnsignedInt(BE.getShort(b, 34 + 2));
         int tcpLen = (((b[34 + 12]) >> 4) & 0x0f) * 4;
 
         int payloadOff = 34 + tcpLen;
@@ -127,11 +127,11 @@
         p.layers |= Packet.LAYER_IP;
         p.ip4.srcIp = mkArray(b, 14 + 12, 4);
         p.ip4.dstIp = mkArray(b, 14 + 16, 4);
-        int ipTotalLen = BE.loadS(b, 14 + 2);
+        int ipTotalLen = BE.getShort(b, 14 + 2);
 
         p.layers |= Packet.LAYER_TCP;
-        p.tcp.srcPort = Short.toUnsignedInt(BE.loadS(b, 34));
-        p.tcp.dstPort = Short.toUnsignedInt(BE.loadS(b, 34 + 2));
+        p.tcp.srcPort = Short.toUnsignedInt(BE.getShort(b, 34));
+        p.tcp.dstPort = Short.toUnsignedInt(BE.getShort(b, 34 + 2));
         int tcpLen = (((b[34 + 12]) >> 4) & 0x0f) * 4;
 
         p.payloadOffset = 34 + tcpLen;
--- a/stress-tester-benchmark/src/main/java/com/passus/http/HttpUtilsBenchmark.java	Fri Oct 06 10:03:29 2017 +0200
+++ b/stress-tester-benchmark/src/main/java/com/passus/http/HttpUtilsBenchmark.java	Fri Oct 06 10:42:04 2017 +0200
@@ -1,6 +1,6 @@
 package com.passus.http;
 
-import com.passus.st.utils.AsciiUtils;
+import com.passus.commons.AsciiUtils;
 import java.util.concurrent.TimeUnit;
 import org.openjdk.jmh.annotations.Benchmark;
 import org.openjdk.jmh.annotations.BenchmarkMode;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stress-tester-benchmark/src/main/java/com/passus/net/http/CookieDate.java	Fri Oct 06 10:42:04 2017 +0200
@@ -0,0 +1,77 @@
+package com.passus.net.http;
+
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+import java.util.concurrent.TimeUnit;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+/**
+ *
+ * @author mikolaj.podbielski
+ */
+@State(Scope.Thread)
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(value = 1)
+@Measurement(iterations = 6)
+@Warmup(iterations = 5)
+public class CookieDate {
+
+    private static final long DATE_MILLIS = 1252487340_000L; // Wed Sep 09 11:09:00 CEST 2009
+
+    private static final String[] STRINGS = {
+        "Wed, 09-Sep-2009 09:09:00 GMT",
+        "Wed, 09 Sep 2009 09:09:00 GMT",
+        "Wed Sep 09 2009 09:09:00 GMT+0000",
+        "Wed, 09-Sep-09 09:09:00 GMT",
+        "Wed, 09 Sep 09 09:09:00 GMT",
+        "Wednesday, 09-Sep-09 09:09:00 GMT",
+        "blah"
+    };
+
+    @Param({"0", "1", "2", "3", "4", "5", "6"})
+    private int idx;
+
+//    @Benchmark
+    public long parse0HttpCookieDecoder() {
+        return HttpSetCookieDecoder.parseExpires(STRINGS[idx]);
+    }
+
+//    @Benchmark
+    public Date parse1Netty() {
+        return io.netty.handler.codec.DateFormatter.parseHttpDate(STRINGS[idx]);
+    }
+
+//    @Benchmark
+    public Date parse2JDK() {
+        LocalDateTime ldt = LocalDateTime.parse(STRINGS[idx], DateTimeFormatter.RFC_1123_DATE_TIME);
+        return Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant());
+    }
+
+    @Benchmark
+    public Date parse2NettyCopy() {
+        return HttpDateFormatter.parseHttpDate(STRINGS[idx]);
+    }
+
+
+    public static void main(String[] args) throws RunnerException {
+        HttpDateFormatter.parseHttpDate(STRINGS[0]);
+        Options opt = new OptionsBuilder().include(CookieDate.class.getSimpleName() + ".*").build();
+        new Runner(opt).run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stress-tester-benchmark/src/main/java/com/passus/net/http/HttpCookieDecoderBenchmark.java	Fri Oct 06 10:42:04 2017 +0200
@@ -0,0 +1,54 @@
+package com.passus.net.http;
+
+import com.passus.ambience.protocol.http.HttpCookieHeaderParser;
+import com.passus.data.ByteString;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+/**
+ *
+ * @author Mirosław Hawrot
+ */
+@State(Scope.Thread)
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(value = 1)
+@Measurement(iterations = 6)
+@Warmup(iterations = 4)
+public class HttpCookieDecoderBenchmark {
+
+    private final HttpSetCookieDecoder setCookieDecoder = new HttpSetCookieDecoder();
+    private final String setCookieHeader = "someCookie=someValue;path=/somepath;domain = somedomain ; HttpOnly; Secure;";
+    private final ByteString setCookieHeaderBs = ByteString.create(setCookieHeader);
+
+    @Benchmark
+    public int decode_HttpSetCookieDecoder() {
+        HttpCookies cookies = setCookieDecoder.decode(setCookieHeaderBs, 0, false);
+        return cookies.size();
+    }
+
+    @Benchmark
+    public int decode_HttpCookieHeaderParser() {
+        List<java.net.HttpCookie> cookies = HttpCookieHeaderParser.parseSetCookieHeader(setCookieHeader);
+        return cookies.size();
+    }
+
+    public static void main(String[] args) throws RunnerException {
+        Options opt = new OptionsBuilder().include(HttpCookieDecoderBenchmark.class.getSimpleName() + ".*").build();
+        new Runner(opt).run();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stress-tester-benchmark/src/main/java/com/passus/net/http/HttpCookieDecoderBennchmark.java	Fri Oct 06 10:42:04 2017 +0200
@@ -0,0 +1,53 @@
+package com.passus.net.http;
+
+import java.io.IOException;
+import java.net.HttpCookie;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+/**
+ *
+ * @author Mirosław Hawrot
+ */
+@State(Scope.Thread)
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(value = 1)
+@Measurement(iterations = 10)
+@Warmup(iterations = 6)
+public class HttpCookieDecoderBennchmark {
+
+    private final String cookieStr = "someCookie=someValue;path='/somepath';domain = \"somedomain\" ; HttpOnly; Secure;";
+    private final HttpSetCookieDecoder decoder = new HttpSetCookieDecoder();
+
+    @Benchmark
+    public int testJDKDecoder() throws IOException {
+        List<HttpCookie> cookies = HttpCookie.parse("Set-Cookie:" + cookieStr);
+        return cookies == null ? 1 : -1;
+    }
+
+    @Benchmark
+    public int testDecoder() throws IOException {
+        HttpCookies cookies = decoder.decode(cookieStr);
+        return cookies == null ? 1 : -1;
+    }
+
+    public static void main(String[] args) throws RunnerException, IOException {
+        Options opt = new OptionsBuilder().include(HttpCookieDecoderBennchmark.class.getSimpleName() + ".*").build();
+        new Runner(opt).run();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stress-tester-benchmark/src/main/java/com/passus/net/http/HttpDigestMD5Benchmark.java	Fri Oct 06 10:42:04 2017 +0200
@@ -0,0 +1,145 @@
+package com.passus.net.http;
+
+import com.passus.data.ByteString;
+import com.passus.data.ByteStringImpl;
+import com.passus.utils.AllocationUtils;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.concurrent.TimeUnit;
+import org.bouncycastle.jce.provider.JDKMessageDigest;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+/**
+ *
+ * @author mikolaj.podbielski
+ */
+@State(Scope.Thread)
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(value = 1)
+@Measurement(iterations = 6)
+@Warmup(iterations = 4)
+public class HttpDigestMD5Benchmark {
+
+    private final byte COLON = ':';
+    private final byte[] user = "user".getBytes();
+    private final byte[] password = "password".getBytes();
+    private final byte[] realm = "11111111112222222222333333333344".getBytes();
+    private final ByteString ubs = new ByteStringImpl(user);
+    private final ByteString rbs = new ByteStringImpl(realm);
+    private final ByteString pbs = new ByteStringImpl(password);
+
+    @Benchmark
+    public MessageDigest getMD5() throws NoSuchAlgorithmException {
+        return MessageDigest.getInstance("MD5");
+    }
+
+    @Benchmark
+    public JDKMessageDigest.MD5 getMD5BC() {
+        return new JDKMessageDigest.MD5();
+    }
+
+    @Benchmark
+    public byte[] digestMultiCall() throws NoSuchAlgorithmException {
+        MessageDigest md = getMD5();
+        md.update(user);
+        md.update(COLON);
+        md.update(realm);
+        md.update(COLON);
+        md.update(password);
+        return md.digest();
+    }
+
+    @Benchmark
+    public byte[] digestWithBuffer() throws NoSuchAlgorithmException {
+        MessageDigest md = getMD5();
+        byte[] buff = new byte[user.length + realm.length + password.length + 2];
+        System.arraycopy(user, 0, buff, 0, user.length);
+        buff[user.length] = COLON;
+        System.arraycopy(realm, 0, buff, user.length + 1, realm.length);
+        buff[user.length + realm.length + 1] = COLON;
+        System.arraycopy(password, 0, buff, user.length + realm.length + 2, password.length);
+        return md.digest(buff);
+    }
+
+    @Benchmark
+    public byte[] digestMultiCallBC() {
+        JDKMessageDigest.MD5 md = getMD5BC();
+        md.update(user);
+        md.update(COLON);
+        md.update(realm);
+        md.update(COLON);
+        md.update(password);
+        return md.digest();
+    }
+
+    @Benchmark
+    public byte[] digestWithBufferBC() {
+        JDKMessageDigest.MD5 md = getMD5BC();
+        byte[] buff = new byte[user.length + realm.length + password.length + 2];
+        System.arraycopy(user, 0, buff, 0, user.length);
+        buff[user.length] = COLON;
+        System.arraycopy(realm, 0, buff, user.length + 1, realm.length);
+        buff[user.length + realm.length + 1] = COLON;
+        System.arraycopy(password, 0, buff, user.length + realm.length + 2, password.length);
+        return md.digest(buff);
+    }
+    
+//    @Benchmark
+//    public byte[] copy() {
+//        JDKMessageDigest.MD5 md = getMD5BC();
+//        md.update(ubs.getBytes());
+//        md.update(COLON);
+//        md.update(rbs.getBytes());
+//        md.update(COLON);
+//        md.update(pbs.getBytes());
+//        return md.digest();
+//    }
+
+    public static void main(String[] args) throws Exception {
+        Options opt = new OptionsBuilder().include(HttpDigestMD5Benchmark.class.getSimpleName() + ".*").build();
+        new Runner(opt).run();
+
+        HttpDigestMD5Benchmark bench = new HttpDigestMD5Benchmark();
+
+        AllocationUtils au = new AllocationUtils();
+        au.checkAllocation("jdk-mc", bench::digestMultiCall);
+        au.checkAllocation(" bc-mc", bench::digestMultiCallBC);
+        au.checkAllocation("jdk-buff", bench::digestWithBuffer);
+        au.checkAllocation(" bc-buff", bench::digestWithBufferBC);
+
+        printHex(bench.digestMultiCall());
+        printHex(bench.digestMultiCallBC());
+        printHex(bench.digestWithBuffer());
+        printHex(bench.digestWithBufferBC());
+    }
+
+    private final static char[] HEX = {
+        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
+    };
+
+    public static String bytesToHex(byte[] bytes) {
+        char[] hexChars = new char[bytes.length * 2];
+        for (int j = 0; j < bytes.length; j++) {
+            int v = bytes[j] & 0xFF;
+            hexChars[j * 2] = HEX[v >>> 4];
+            hexChars[j * 2 + 1] = HEX[v & 0x0F];
+        }
+        return new String(hexChars);
+    }
+
+    public static void printHex(byte[] bytes) {
+        System.out.println(bytesToHex(bytes));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stress-tester-benchmark/src/main/java/com/passus/net/http/HttpRequestDecodingBenchmark.java	Fri Oct 06 10:42:04 2017 +0200
@@ -0,0 +1,101 @@
+package com.passus.net.http;
+
+import com.passus.utils.AllocationUtils;
+import java.util.concurrent.TimeUnit;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+
+/**
+ *
+ * @author Mirosław Hawrot
+ */
+@State(Scope.Thread)
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(value = 1)
+@Measurement(iterations = 6)
+@Warmup(iterations = 4)
+public class HttpRequestDecodingBenchmark {
+
+    private String headersStr = "Host: testHost\r\n"
+            + "Host2:testHost2\r\n"
+            + "\r\n";
+
+    private byte[] headersBytes;
+
+    private String reqStr = "GET /resource HTTP/1.1\r\n"
+            + headersStr;
+
+    private byte[] reqBytes;
+
+    {
+        try {
+            reqBytes = reqStr.getBytes("US-ASCII");
+            headersBytes = headersStr.getBytes("US-ASCII");
+        } catch (Exception e) {
+        }
+    }
+
+    private final com.passus.ambience.protocol.http.HttpRequest ambRequest = new com.passus.ambience.protocol.http.HttpRequest();
+    private final HttpRequestDecoder decoderStrict = new HttpRequestDecoder(true);
+    private final HttpRequestDecoder decoderNotStrict = new HttpRequestDecoder(false);
+    private final HttpHeadersDecoder headersDecoderNotStrict = new HttpHeadersDecoder(false);
+
+    @Benchmark
+    public int testAmbDecoder() throws Exception {
+        com.passus.ambience.protocol.http.HttpRequest ambRequest = new com.passus.ambience.protocol.http.HttpRequest();
+        return ambRequest.decode(reqBytes, 0);
+    }
+
+    //@Benchmark
+    public int testDecoder_Strict() throws Exception {
+        return decoderStrict.decode(reqBytes);
+    }
+
+    //@Benchmark
+    public int testDecoder_NotStrict() throws Exception {
+        return decoderNotStrict.decode(reqBytes);
+    }
+
+    @Benchmark
+    public int testHeadersDecoder_NotStrict() throws Exception {
+        int res = headersDecoderNotStrict.decode(headersBytes);
+        headersDecoderNotStrict.clear();
+        return res;
+    }
+
+    public static void main(String[] args) throws Exception {
+        //Options opt = new OptionsBuilder().include(HttpRequestDecodingBenchmark.class.getSimpleName() + ".*").build();
+        //new Runner(opt).run();
+
+        HttpRequestDecodingBenchmark bench = new HttpRequestDecodingBenchmark();
+        //System.out.println(bench.testAmbDecoder());
+        //System.out.println(bench.testDecoder_Strict());
+        //System.out.println(bench.testDecoder_NotStrict());
+        long start = System.currentTimeMillis();
+        for (int i = 0; i < 100000; i++) {
+            bench.testAmbDecoder();
+        }
+        System.out.println(System.currentTimeMillis() - start);
+
+        start = System.currentTimeMillis();
+        for (int i = 0; i < 100000; i++) {
+            bench.testHeadersDecoder_NotStrict();
+        }
+        System.out.println(System.currentTimeMillis() - start);
+        
+        AllocationUtils au = new AllocationUtils();
+        au.setOverheadBase(bench.headersStr.length());
+        au.checkAllocation("AmbienceDecoder", bench::testAmbDecoder);
+        au.checkAllocation("HeadersNotStrict", bench::testHeadersDecoder_NotStrict);
+        au.checkAllocation("NotStrict", bench::testDecoder_NotStrict);
+        au.checkAllocation("Strict", bench::testDecoder_Strict);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stress-tester-benchmark/src/main/java/com/passus/net/http/UrlBenchmark.java	Fri Oct 06 10:42:04 2017 +0200
@@ -0,0 +1,67 @@
+package com.passus.net.http;
+
+import com.passus.data.ByteString;
+import com.passus.utils.AllocationUtils;
+import java.util.concurrent.TimeUnit;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+/**
+ *
+ * @author mikolaj.podbielski
+ */
+@State(Scope.Thread)
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(value = 1)
+@Measurement(iterations = 10)
+@Warmup(iterations = 6)
+public class UrlBenchmark {
+
+    private final String urlStr_full = "http://username:password@example.com:123/path/data?key=value&key2=value2#fragid1";
+    private final ByteString urlByteStr_full = ByteString.create(urlStr_full);
+    private final String urlStr_simple = "http://example.com/path/";
+    private final ByteString urlByteStr_simple = ByteString.create(urlStr_simple);
+
+    @Benchmark
+    public URL stFull() throws Exception {
+        return URL.parse(urlByteStr_full);
+    }
+
+    @Benchmark
+    public URL stSimple() throws Exception {
+        return URL.parse(urlByteStr_simple);
+    }
+
+    @Benchmark
+    public java.net.URL jdkFull() throws Exception {
+        return new java.net.URL(urlStr_full);
+    }
+
+    @Benchmark
+    public java.net.URL jdkSimple() throws Exception {
+        return new java.net.URL(urlStr_simple);
+    }
+
+    public static void main(String[] args) throws Exception {
+        UrlBenchmark hub = new UrlBenchmark();
+        AllocationUtils au = new AllocationUtils();
+        au.checkAllocation(" st simple", hub::stSimple);
+        au.checkAllocation(" st full", hub::stFull);
+        au.checkAllocation("jdk simple", hub::jdkSimple);
+        au.checkAllocation("jdk full", hub::jdkFull);
+
+        Options opt = new OptionsBuilder().include(UrlBenchmark.class.getSimpleName() + ".*").build();
+        new Runner(opt).run();
+    }
+}
--- a/stress-tester-benchmark/src/main/java/com/passus/packetcounter/PacketCounter.java	Fri Oct 06 10:03:29 2017 +0200
+++ b/stress-tester-benchmark/src/main/java/com/passus/packetcounter/PacketCounter.java	Fri Oct 06 10:42:04 2017 +0200
@@ -1,227 +1,229 @@
-package com.passus.packetcounter;
-
-import com.passus.pcap.AdvancedPacketHandler;
-import com.passus.pcap.PacketHandler;
-import com.passus.st.reader.ProgressListener;
-import com.passus.st.reader.pcap.PcapFileHeader;
-import com.passus.st.reader.pcap.PcapListener;
-import com.passus.st.reader.pcap.PcapReader;
-import com.passus.st.reader.pcap.PcapReader2;
-import com.passus.st.reader.pcap.PcapReader3;
-import com.passus.st.reader.pcap.PcapRecord;
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-import org.jnetpcap.JBufferHandler;
-import org.jnetpcap.PcapHeader;
-import org.jnetpcap.nio.JBuffer;
-import org.jnetpcap.packet.JPacket;
-import org.jnetpcap.packet.JPacketHandler;
-import org.jnetpcap.protocol.network.Ip4;
-import org.openjdk.jmh.annotations.*;
-import org.openjdk.jmh.runner.Runner;
-import org.openjdk.jmh.runner.RunnerException;
-import org.openjdk.jmh.runner.options.Options;
-import org.openjdk.jmh.runner.options.OptionsBuilder;
-import org.pcap4j.core.PacketListener;
-import org.pcap4j.core.PcapHandle;
-import org.pcap4j.core.Pcaps;
-import org.pcap4j.core.RawPacketListener;
-import org.pcap4j.packet.Packet;
-
-/**
- *
- * @author mikolaj.podbielski
- */
-@State(Scope.Thread)
-@BenchmarkMode(Mode.AverageTime)
-@OutputTimeUnit(TimeUnit.MILLISECONDS)
-@Fork(value = 1)
-@Measurement(iterations = 6)
-@Warmup(iterations = 5)
-public class PacketCounter {
-
-    // 23674 packets with VLAN -> 42ms 620ms -> 1.76us 26.17 us
-    private static final String PATH = "/devel/http/uat/UAT2.pcap";
-    // 9709 packets no VLAN -> 16.5ms 249ms -> 1.70us 25.67us
-    //private static final String PATH = "c:\\tmp\\UAT_traffic.pcap";
-
-    private static abstract class AbstractHandlerImpl {
-
-        protected final Ip4 ip4 = new Ip4();
-        protected int count;
-    }
-
-    private static class JPacketHandlerImpl extends AbstractHandlerImpl implements JPacketHandler<Object> {
-
-        @Override
-        public void nextPacket(JPacket packet, Object user) {
-            ++count;
-        }
-    }
-
-    private static class JBufferHandlerImpl extends AbstractHandlerImpl implements JBufferHandler<Object> {
-
-        @Override
-        public void nextPacket(PcapHeader header, JBuffer buffer, Object user) {
-            if (header.caplen() >= 0) {
-                ++count;
-            }
-        }
-    }
-
-    private static class PcapListenerImpl extends AbstractHandlerImpl implements PcapListener {
-
-        @Override
-        public void fileHeaderRead(PcapFileHeader fileHeader) {
-        }
-
-        @Override
-        public void recordRead(PcapRecord record) {
-            ++count;
-        }
-    }
-
-    private static class PacketListenerImpl extends AbstractHandlerImpl implements PacketListener {
-
-        @Override
-        public void gotPacket(Packet packet) {
-            ++count;
-        }
-    }
-
-    private static class RawPacketListenerImpl extends AbstractHandlerImpl implements RawPacketListener {
-
-        @Override
-        public void gotPacket(byte[] packet) {
-            ++count;
-        }
-    }
-
-    private static class ByteArrayHandlerImpl extends AbstractHandlerImpl implements PacketHandler, AdvancedPacketHandler {
-
-        @Override
-        public void handle(byte[] ba, long timestamp, int wirelen) {
-            ++count;
-        }
-
-        @Override
-        public void handle(PacketData pd) {
-            ++count;
-            pd.copyPayload();
-        }
-    }
+// NIE DAŁO RADY TEGO PRZYWRÓCIĆ, ZBYT DUŻO ZMIAN I SKASOWANYCH KLAS
 
-    private static class NoPayloadBAH extends AbstractHandlerImpl implements AdvancedPacketHandler {
-
-        @Override
-        public void handle(PacketData pd) {
-            ++count;
-        }
-    }
-
-    @Benchmark
-    public int testJNetPcapJPacketHandler() {
-        JPacketHandlerImpl handler = new JPacketHandlerImpl();
-        org.jnetpcap.Pcap.openOffline(PATH, new StringBuilder()).loop(-1, handler, null);
-        return handler.count;
-    }
-
-    @Benchmark
-    public int testJNetPcapJBufferHandler() {
-        JBufferHandlerImpl handler = new JBufferHandlerImpl();
-        org.jnetpcap.Pcap.openOffline(PATH, new StringBuilder()).loop(-1, handler, null);
-        return handler.count;
-    }
-
-    @Benchmark
-    public int testPcap4jPacketListener() throws Exception {
-        PcapHandle pcap = Pcaps.openOffline(PATH);
-        PacketListenerImpl listener = new PacketListenerImpl();
-        pcap.loop(0, listener);
-        return listener.count;
-    }
-
-    @Benchmark
-    public int testPcap4jRawPacketListener() throws Exception {
-        PcapHandle pcap = Pcaps.openOffline(PATH);
-        RawPacketListenerImpl listener = new RawPacketListenerImpl();
-        pcap.loop(-1, listener);
-        return listener.count;
-    }
-
-    @Benchmark
-    public int testPcapReader() throws IOException {
-        PcapListenerImpl listener = new PcapListenerImpl();
-        new PcapReader().read(PATH, listener, ProgressListener.NULL_LISTENER);
-        return listener.count;
-    }
-
-    @Benchmark
-    public int testPcapReader2() throws IOException {
-        PcapReader2 reader = new PcapReader2(PATH);
-        int count = 0;
-        while (reader.read() != null) {
-            ++count;
-        }
-        return count;
-    }
-
-    @Benchmark
-    public int testPcapReader3() throws IOException {
-        PcapReader3 reader = new PcapReader3(PATH);
-        int count = 0;
-        while (reader.read() != null) {
-            ++count;
-        }
-        return count;
-    }
-
-    @Benchmark
-    public int testPassusPcapHandler() throws Exception {
-        com.passus.pcap.Pcap pcap = com.passus.pcap.Pcap.openOffline(PATH, new StringBuilder());
-        ByteArrayHandlerImpl handler = new ByteArrayHandlerImpl();
-        pcap.loop(-1, handler);
-        pcap.close();
-        return handler.count;
-    }
-
-    @Benchmark
-    public int testPassusPcapHandler4() throws Exception {
-        com.passus.pcap.Pcap pcap = com.passus.pcap.Pcap.openOffline(PATH, new StringBuilder());
-        ByteArrayHandlerImpl handler = new ByteArrayHandlerImpl();
-        pcap.loop2(-1, handler);
-        pcap.close();
-        return handler.count;
-    }
-
-    @Benchmark
-    public int testPassusPcapHandler4NoPayload() throws Exception {
-        com.passus.pcap.Pcap pcap = com.passus.pcap.Pcap.openOffline(PATH, new StringBuilder());
-        NoPayloadBAH handler = new NoPayloadBAH();
-        pcap.loop2(-1, handler);
-        pcap.close();
-        return handler.count;
-    }
-
-    public static void main(String[] args) throws RunnerException, IOException, Exception {
-        Options opt = new OptionsBuilder().include(PacketCounter.class.getSimpleName() + ".*").build();
-        new Runner(opt).run();
-
-        PacketCounter pc = new PacketCounter();
-        System.out.println(pc.testJNetPcapJBufferHandler());
-        System.out.println(pc.testJNetPcapJPacketHandler());
-        System.out.println(pc.testPcap4jPacketListener());
-        System.out.println(pc.testPcap4jRawPacketListener());
-        System.out.println(pc.testPcapReader());
-        System.out.println(pc.testPcapReader2());
-        System.out.println(pc.testPcapReader3());
-        System.out.println(pc.testPassusPcapHandler());
-        System.out.println(pc.testPassusPcapHandler4());
-        System.out.println(pc.testPassusPcapHandler4NoPayload());
-        /*
-        JIT compiler profilers (COMP / HS_COMP) are recommended for use 
-        on most of benchmarks – they will let you know if you have 
-        insufficiently warmed up your code. 
-         */
-    }
-}
+//package com.passus.packetcounter;
+//
+//import com.passus.pcap.AdvancedPacketHandler;
+//import com.passus.pcap.PacketHandler;
+//import com.passus.st.reader.ProgressListener;
+//import com.passus.st.reader.pcap.PcapFileHeader;
+//import com.passus.st.reader.pcap.PcapListener;
+//import com.passus.st.reader.pcap.PcapReader;
+//import com.passus.st.reader.pcap.PcapReader2;
+//import com.passus.st.reader.pcap.PcapReader3;
+//import com.passus.st.reader.pcap.PcapRecord;
+//import java.io.IOException;
+//import java.util.concurrent.TimeUnit;
+//import org.jnetpcap.JBufferHandler;
+//import org.jnetpcap.PcapHeader;
+//import org.jnetpcap.nio.JBuffer;
+//import org.jnetpcap.packet.JPacket;
+//import org.jnetpcap.packet.JPacketHandler;
+//import org.jnetpcap.protocol.network.Ip4;
+//import org.openjdk.jmh.annotations.*;
+//import org.openjdk.jmh.runner.Runner;
+//import org.openjdk.jmh.runner.RunnerException;
+//import org.openjdk.jmh.runner.options.Options;
+//import org.openjdk.jmh.runner.options.OptionsBuilder;
+//import org.pcap4j.core.PacketListener;
+//import org.pcap4j.core.PcapHandle;
+//import org.pcap4j.core.Pcaps;
+//import org.pcap4j.core.RawPacketListener;
+//import org.pcap4j.packet.Packet;
+//
+///**
+// *
+// * @author mikolaj.podbielski
+// */
+//@State(Scope.Thread)
+//@BenchmarkMode(Mode.AverageTime)
+//@OutputTimeUnit(TimeUnit.MILLISECONDS)
+//@Fork(value = 1)
+//@Measurement(iterations = 6)
+//@Warmup(iterations = 5)
+//public class PacketCounter {
+//
+//    // 23674 packets with VLAN -> 42ms 620ms -> 1.76us 26.17 us
+//    private static final String PATH = "/devel/http/uat/UAT2.pcap";
+//    // 9709 packets no VLAN -> 16.5ms 249ms -> 1.70us 25.67us
+//    //private static final String PATH = "c:\\tmp\\UAT_traffic.pcap";
+//
+//    private static abstract class AbstractHandlerImpl {
+//
+//        protected final Ip4 ip4 = new Ip4();
+//        protected int count;
+//    }
+//
+//    private static class JPacketHandlerImpl extends AbstractHandlerImpl implements JPacketHandler<Object> {
+//
+//        @Override
+//        public void nextPacket(JPacket packet, Object user) {
+//            ++count;
+//        }
+//    }
+//
+//    private static class JBufferHandlerImpl extends AbstractHandlerImpl implements JBufferHandler<Object> {
+//
+//        @Override
+//        public void nextPacket(PcapHeader header, JBuffer buffer, Object user) {
+//            if (header.caplen() >= 0) {
+//                ++count;
+//            }
+//        }
+//    }
+//
+//    private static class PcapListenerImpl extends AbstractHandlerImpl implements PcapListener {
+//
+//        @Override
+//        public void fileHeaderRead(PcapFileHeader fileHeader) {
+//        }
+//
+//        @Override
+//        public void recordRead(PcapRecord record) {
+//            ++count;
+//        }
+//    }
+//
+//    private static class PacketListenerImpl extends AbstractHandlerImpl implements PacketListener {
+//
+//        @Override
+//        public void gotPacket(Packet packet) {
+//            ++count;
+//        }
+//    }
+//
+//    private static class RawPacketListenerImpl extends AbstractHandlerImpl implements RawPacketListener {
+//
+//        @Override
+//        public void gotPacket(byte[] packet) {
+//            ++count;
+//        }
+//    }
+//
+//    private static class ByteArrayHandlerImpl extends AbstractHandlerImpl implements PacketHandler, AdvancedPacketHandler {
+//
+//        @Override
+//        public void handle(byte[] ba, long timestamp, int wirelen) {
+//            ++count;
+//        }
+//
+//        @Override
+//        public void handle(PacketData pd) {
+//            ++count;
+//            pd.copyPayload();
+//        }
+//    }
+//
+//    private static class NoPayloadBAH extends AbstractHandlerImpl implements AdvancedPacketHandler {
+//
+//        @Override
+//        public void handle(PacketData pd) {
+//            ++count;
+//        }
+//    }
+//
+//    @Benchmark
+//    public int testJNetPcapJPacketHandler() {
+//        JPacketHandlerImpl handler = new JPacketHandlerImpl();
+//        org.jnetpcap.Pcap.openOffline(PATH, new StringBuilder()).loop(-1, handler, null);
+//        return handler.count;
+//    }
+//
+//    @Benchmark
+//    public int testJNetPcapJBufferHandler() {
+//        JBufferHandlerImpl handler = new JBufferHandlerImpl();
+//        org.jnetpcap.Pcap.openOffline(PATH, new StringBuilder()).loop(-1, handler, null);
+//        return handler.count;
+//    }
+//
+//    @Benchmark
+//    public int testPcap4jPacketListener() throws Exception {
+//        PcapHandle pcap = Pcaps.openOffline(PATH);
+//        PacketListenerImpl listener = new PacketListenerImpl();
+//        pcap.loop(0, listener);
+//        return listener.count;
+//    }
+//
+//    @Benchmark
+//    public int testPcap4jRawPacketListener() throws Exception {
+//        PcapHandle pcap = Pcaps.openOffline(PATH);
+//        RawPacketListenerImpl listener = new RawPacketListenerImpl();
+//        pcap.loop(-1, listener);
+//        return listener.count;
+//    }
+//
+//    @Benchmark
+//    public int testPcapReader() throws IOException {
+//        PcapListenerImpl listener = new PcapListenerImpl();
+//        new PcapReader().read(PATH, listener, ProgressListener.NULL_LISTENER);
+//        return listener.count;
+//    }
+//
+//    @Benchmark
+//    public int testPcapReader2() throws IOException {
+//        PcapReader2 reader = new PcapReader2(PATH);
+//        int count = 0;
+//        while (reader.read() != null) {
+//            ++count;
+//        }
+//        return count;
+//    }
+//
+//    @Benchmark
+//    public int testPcapReader3() throws IOException {
+//        PcapReader3 reader = new PcapReader3(PATH);
+//        int count = 0;
+//        while (reader.read() != null) {
+//            ++count;
+//        }
+//        return count;
+//    }
+//
+//    @Benchmark
+//    public int testPassusPcapHandler() throws Exception {
+//        com.passus.pcap.Pcap pcap = com.passus.pcap.Pcap.openOffline(PATH, new StringBuilder());
+//        ByteArrayHandlerImpl handler = new ByteArrayHandlerImpl();
+//        pcap.loop(-1, handler);
+//        pcap.close();
+//        return handler.count;
+//    }
+//
+//    @Benchmark
+//    public int testPassusPcapHandler4() throws Exception {
+//        com.passus.pcap.Pcap pcap = com.passus.pcap.Pcap.openOffline(PATH, new StringBuilder());
+//        ByteArrayHandlerImpl handler = new ByteArrayHandlerImpl();
+//        pcap.loop2(-1, handler);
+//        pcap.close();
+//        return handler.count;
+//    }
+//
+//    @Benchmark
+//    public int testPassusPcapHandler4NoPayload() throws Exception {
+//        com.passus.pcap.Pcap pcap = com.passus.pcap.Pcap.openOffline(PATH, new StringBuilder());
+//        NoPayloadBAH handler = new NoPayloadBAH();
+//        pcap.loop2(-1, handler);
+//        pcap.close();
+//        return handler.count;
+//    }
+//
+//    public static void main(String[] args) throws RunnerException, IOException, Exception {
+//        Options opt = new OptionsBuilder().include(PacketCounter.class.getSimpleName() + ".*").build();
+//        new Runner(opt).run();
+//
+//        PacketCounter pc = new PacketCounter();
+//        System.out.println(pc.testJNetPcapJBufferHandler());
+//        System.out.println(pc.testJNetPcapJPacketHandler());
+//        System.out.println(pc.testPcap4jPacketListener());
+//        System.out.println(pc.testPcap4jRawPacketListener());
+//        System.out.println(pc.testPcapReader());
+//        System.out.println(pc.testPcapReader2());
+//        System.out.println(pc.testPcapReader3());
+//        System.out.println(pc.testPassusPcapHandler());
+//        System.out.println(pc.testPassusPcapHandler4());
+//        System.out.println(pc.testPassusPcapHandler4NoPayload());
+//        /*
+//        JIT compiler profilers (COMP / HS_COMP) are recommended for use 
+//        on most of benchmarks – they will let you know if you have 
+//        insufficiently warmed up your code. 
+//         */
+//    }
+//}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stress-tester-benchmark/src/main/java/com/passus/st/client/http/filter/HttpMessagePredicateBenchmark.java	Fri Oct 06 10:42:04 2017 +0200
@@ -0,0 +1,58 @@
+package com.passus.st.client.http.filter;
+
+import com.passus.filter.config.PredicateNodeTransformer;
+import com.passus.st.AppUtils;
+import com.passus.utils.AllocationUtils;
+import java.util.concurrent.TimeUnit;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+/**
+ *
+ * @author mikolaj.podbielski
+ */
+@State(Scope.Thread)
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.MICROSECONDS)
+@Fork(value = 1)
+@Measurement(iterations = 6)
+@Warmup(iterations = 6)
+public class HttpMessagePredicateBenchmark {
+
+    private final PredicateNodeTransformer nodeTransformer = new PredicateNodeTransformer();
+
+    @Setup
+    public static void beforeClass() {
+        AppUtils.registerAll();
+    }
+
+    @TearDown
+    public static void afterClass() {
+        AppUtils.unregisterAll();
+    }
+
+    @Benchmark
+    public Object test1() {
+        return this;
+    }
+
+    public static void main(String[] args) throws Throwable {
+        Options opt = new OptionsBuilder().include(CsrfBenchmark.class.getSimpleName() + ".*").build();
+        new Runner(opt).run();
+
+        AllocationUtils au = new AllocationUtils();
+
+    }
+}
--- a/stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/CookieDate.java	Fri Oct 06 10:03:29 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-package com.passus.st.protocol.http;
-
-import com.passus.st.protocol.http.HttpDateFormatter;
-import com.passus.st.protocol.http.HttpSetCookieDecoder;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.annotations.BenchmarkMode;
-import org.openjdk.jmh.annotations.Fork;
-import org.openjdk.jmh.annotations.Measurement;
-import org.openjdk.jmh.annotations.Mode;
-import org.openjdk.jmh.annotations.OutputTimeUnit;
-import org.openjdk.jmh.annotations.Param;
-import org.openjdk.jmh.annotations.Scope;
-import org.openjdk.jmh.annotations.State;
-import org.openjdk.jmh.annotations.Warmup;
-import org.openjdk.jmh.runner.Runner;
-import org.openjdk.jmh.runner.RunnerException;
-import org.openjdk.jmh.runner.options.Options;
-import org.openjdk.jmh.runner.options.OptionsBuilder;
-
-/**
- *
- * @author mikolaj.podbielski
- */
-@State(Scope.Thread)
-@BenchmarkMode(Mode.AverageTime)
-@OutputTimeUnit(TimeUnit.NANOSECONDS)
-@Fork(value = 1)
-@Measurement(iterations = 6)
-@Warmup(iterations = 5)
-public class CookieDate {
-
-    private static final long DATE_MILLIS = 1252487340_000L; // Wed Sep 09 11:09:00 CEST 2009
-
-    private static final String[] STRINGS = {
-        "Wed, 09-Sep-2009 09:09:00 GMT",
-        "Wed, 09 Sep 2009 09:09:00 GMT",
-        "Wed Sep 09 2009 09:09:00 GMT+0000",
-        "Wed, 09-Sep-09 09:09:00 GMT",
-        "Wed, 09 Sep 09 09:09:00 GMT",
-        "Wednesday, 09-Sep-09 09:09:00 GMT",
-        "blah"
-    };
-
-    @Param({"0", "1", "2", "3", "4", "5", "6"})
-    private int idx;
-
-//    @Benchmark
-    public long parse0HttpCookieDecoder() {
-        return HttpSetCookieDecoder.parseMaxAge(STRINGS[idx]);
-    }
-
-//    @Benchmark
-    public Date parse1Netty() {
-        return io.netty.handler.codec.DateFormatter.parseHttpDate(STRINGS[idx]);
-    }
-
-//    @Benchmark
-    public Date parse2JDK() {
-        LocalDateTime ldt = LocalDateTime.parse(STRINGS[idx], DateTimeFormatter.RFC_1123_DATE_TIME);
-        return Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant());
-    }
-
-    @Benchmark
-    public Date parse2NettyCopy() {
-        return HttpDateFormatter.parseHttpDate(STRINGS[idx]);
-    }
-
-
-    public static void main(String[] args) throws RunnerException {
-        HttpDateFormatter.parseHttpDate(STRINGS[0]);
-        Options opt = new OptionsBuilder().include(CookieDate.class.getSimpleName() + ".*").build();
-        new Runner(opt).run();
-    }
-}
--- a/stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/HttpCookieDecoderBenchmark.java	Fri Oct 06 10:03:29 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-package com.passus.st.protocol.http;
-
-import com.passus.ambience.protocol.http.HttpCookieHeaderParser;
-import com.passus.st.data.ByteString;
-import com.passus.st.data.ByteStringImpl;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.annotations.BenchmarkMode;
-import org.openjdk.jmh.annotations.Fork;
-import org.openjdk.jmh.annotations.Measurement;
-import org.openjdk.jmh.annotations.Mode;
-import org.openjdk.jmh.annotations.OutputTimeUnit;
-import org.openjdk.jmh.annotations.Scope;
-import org.openjdk.jmh.annotations.State;
-import org.openjdk.jmh.annotations.Warmup;
-import org.openjdk.jmh.runner.Runner;
-import org.openjdk.jmh.runner.RunnerException;
-import org.openjdk.jmh.runner.options.Options;
-import org.openjdk.jmh.runner.options.OptionsBuilder;
-
-/**
- *
- * @author Mirosław Hawrot
- */
-@State(Scope.Thread)
-@BenchmarkMode(Mode.AverageTime)
-@OutputTimeUnit(TimeUnit.NANOSECONDS)
-@Fork(value = 1)
-@Measurement(iterations = 6)
-@Warmup(iterations = 4)
-public class HttpCookieDecoderBenchmark {
-
-    private HttpSetCookieDecoder setCookieDecoder = new HttpSetCookieDecoder();
-
-    private String setCookieHeader = "someCookie=someValue;path=/somepath;domain = somedomain ; HttpOnly; Secure;";
-
-    private ByteString setCookieHeaderBs = new ByteStringImpl(setCookieHeader);
-
-    @Benchmark
-    public int decode_HttpSetCookieDecoder() {
-        HttpCookie cookie = setCookieDecoder.decode(setCookieHeaderBs, 0, false);
-        return cookie.getVersion();
-    }
-
-    @Benchmark
-    public int decode_HttpCookieHeaderParser() {
-        List<java.net.HttpCookie> cookies = HttpCookieHeaderParser.parseSetCookieHeader(setCookieHeader);
-        return cookies.size();
-    }
-
-    public static void main(String[] args) throws RunnerException {
-        Options opt = new OptionsBuilder().include(HttpCookieDecoderBenchmark.class.getSimpleName() + ".*").build();
-        new Runner(opt).run();
-    }
-
-}
--- a/stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/HttpCookieDecoderBennchmark.java	Fri Oct 06 10:03:29 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-package com.passus.st.protocol.http;
-
-import java.io.IOException;
-import java.net.HttpCookie;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.annotations.BenchmarkMode;
-import org.openjdk.jmh.annotations.Fork;
-import org.openjdk.jmh.annotations.Measurement;
-import org.openjdk.jmh.annotations.Mode;
-import org.openjdk.jmh.annotations.OutputTimeUnit;
-import org.openjdk.jmh.annotations.Scope;
-import org.openjdk.jmh.annotations.State;
-import org.openjdk.jmh.annotations.Warmup;
-import org.openjdk.jmh.runner.Runner;
-import org.openjdk.jmh.runner.RunnerException;
-import org.openjdk.jmh.runner.options.Options;
-import org.openjdk.jmh.runner.options.OptionsBuilder;
-
-/**
- *
- * @author Mirosław Hawrot
- */
-@State(Scope.Thread)
-@BenchmarkMode(Mode.AverageTime)
-@OutputTimeUnit(TimeUnit.NANOSECONDS)
-@Fork(value = 1)
-@Measurement(iterations = 10)
-@Warmup(iterations = 6)
-public class HttpCookieDecoderBennchmark {
-
-    private String cookieStr = "someCookie=someValue;path='/somepath';domain = \"somedomain\" ; HttpOnly; Secure;";
-
-    private final HttpSetCookieDecoder decoder = new HttpSetCookieDecoder();
-
-    @Benchmark
-    public int testJDKDecoder() throws IOException {
-        List<HttpCookie> cookies = HttpCookie.parse("Set-Cookie:" + cookieStr);
-        return cookies == null ? 1 : -1;
-    }
-
-    @Benchmark
-    public int testDecoder() throws IOException {
-        com.passus.st.protocol.http.HttpCookie cookie = decoder.decode(cookieStr);
-        return cookie == null ? 1 : -1;
-    }
-
-    public static void main(String[] args) throws RunnerException, IOException {
-        Options opt = new OptionsBuilder().include(HttpCookieDecoderBennchmark.class.getSimpleName() + ".*").build();
-        new Runner(opt).run();
-    }
-
-}
--- a/stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/HttpDigestMD5Benchmark.java	Fri Oct 06 10:03:29 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-package com.passus.st.protocol.http;
-
-import com.passus.data.ByteString;
-import com.passus.data.ByteStringImpl;
-import com.passus.utils.AllocationUtils;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.concurrent.TimeUnit;
-import org.bouncycastle.jce.provider.JDKMessageDigest;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.annotations.BenchmarkMode;
-import org.openjdk.jmh.annotations.Fork;
-import org.openjdk.jmh.annotations.Measurement;
-import org.openjdk.jmh.annotations.Mode;
-import org.openjdk.jmh.annotations.OutputTimeUnit;
-import org.openjdk.jmh.annotations.Scope;
-import org.openjdk.jmh.annotations.State;
-import org.openjdk.jmh.annotations.Warmup;
-import org.openjdk.jmh.runner.Runner;
-import org.openjdk.jmh.runner.options.Options;
-import org.openjdk.jmh.runner.options.OptionsBuilder;
-
-/**
- *
- * @author mikolaj.podbielski
- */
-@State(Scope.Thread)
-@BenchmarkMode(Mode.AverageTime)
-@OutputTimeUnit(TimeUnit.NANOSECONDS)
-@Fork(value = 1)
-@Measurement(iterations = 6)
-@Warmup(iterations = 4)
-public class HttpDigestMD5Benchmark {
-
-    private final byte COLON = ':';
-    private final byte[] user = "user".getBytes();
-    private final byte[] password = "password".getBytes();
-    private final byte[] realm = "11111111112222222222333333333344".getBytes();
-    private final ByteString ubs = new ByteStringImpl(user);
-    private final ByteString rbs = new ByteStringImpl(realm);
-    private final ByteString pbs = new ByteStringImpl(password);
-
-    @Benchmark
-    public MessageDigest getMD5() throws NoSuchAlgorithmException {
-        return MessageDigest.getInstance("MD5");
-    }
-
-    @Benchmark
-    public JDKMessageDigest.MD5 getMD5BC() {
-        return new JDKMessageDigest.MD5();
-    }
-
-    @Benchmark
-    public byte[] digestMultiCall() throws NoSuchAlgorithmException {
-        MessageDigest md = getMD5();
-        md.update(user);
-        md.update(COLON);
-        md.update(realm);
-        md.update(COLON);
-        md.update(password);
-        return md.digest();
-    }
-
-    @Benchmark
-    public byte[] digestWithBuffer() throws NoSuchAlgorithmException {
-        MessageDigest md = getMD5();
-        byte[] buff = new byte[user.length + realm.length + password.length + 2];
-        System.arraycopy(user, 0, buff, 0, user.length);
-        buff[user.length] = COLON;
-        System.arraycopy(realm, 0, buff, user.length + 1, realm.length);
-        buff[user.length + realm.length + 1] = COLON;
-        System.arraycopy(password, 0, buff, user.length + realm.length + 2, password.length);
-        return md.digest(buff);
-    }
-
-    @Benchmark
-    public byte[] digestMultiCallBC() {
-        JDKMessageDigest.MD5 md = getMD5BC();
-        md.update(user);
-        md.update(COLON);
-        md.update(realm);
-        md.update(COLON);
-        md.update(password);
-        return md.digest();
-    }
-
-    @Benchmark
-    public byte[] digestWithBufferBC() {
-        JDKMessageDigest.MD5 md = getMD5BC();
-        byte[] buff = new byte[user.length + realm.length + password.length + 2];
-        System.arraycopy(user, 0, buff, 0, user.length);
-        buff[user.length] = COLON;
-        System.arraycopy(realm, 0, buff, user.length + 1, realm.length);
-        buff[user.length + realm.length + 1] = COLON;
-        System.arraycopy(password, 0, buff, user.length + realm.length + 2, password.length);
-        return md.digest(buff);
-    }
-    
-//    @Benchmark
-//    public byte[] copy() {
-//        JDKMessageDigest.MD5 md = getMD5BC();
-//        md.update(ubs.getBytes());
-//        md.update(COLON);
-//        md.update(rbs.getBytes());
-//        md.update(COLON);
-//        md.update(pbs.getBytes());
-//        return md.digest();
-//    }
-
-    public static void main(String[] args) throws Exception {
-        Options opt = new OptionsBuilder().include(HttpDigestMD5Benchmark.class.getSimpleName() + ".*").build();
-        new Runner(opt).run();
-
-        HttpDigestMD5Benchmark bench = new HttpDigestMD5Benchmark();
-
-        AllocationUtils au = new AllocationUtils();
-        au.checkAllocation("jdk-mc", bench::digestMultiCall);
-        au.checkAllocation(" bc-mc", bench::digestMultiCallBC);
-        au.checkAllocation("jdk-buff", bench::digestWithBuffer);
-        au.checkAllocation(" bc-buff", bench::digestWithBufferBC);
-
-        printHex(bench.digestMultiCall());
-        printHex(bench.digestMultiCallBC());
-        printHex(bench.digestWithBuffer());
-        printHex(bench.digestWithBufferBC());
-    }
-
-    private final static char[] HEX = {
-        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
-    };
-
-    public static String bytesToHex(byte[] bytes) {
-        char[] hexChars = new char[bytes.length * 2];
-        for (int j = 0; j < bytes.length; j++) {
-            int v = bytes[j] & 0xFF;
-            hexChars[j * 2] = HEX[v >>> 4];
-            hexChars[j * 2 + 1] = HEX[v & 0x0F];
-        }
-        return new String(hexChars);
-    }
-
-    public static void printHex(byte[] bytes) {
-        System.out.println(bytesToHex(bytes));
-    }
-}
--- a/stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/HttpRequestDecodingBenchmark.java	Fri Oct 06 10:03:29 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-package com.passus.st.protocol.http;
-
-import com.passus.utils.AllocationUtils;
-import java.util.concurrent.TimeUnit;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.annotations.BenchmarkMode;
-import org.openjdk.jmh.annotations.Fork;
-import org.openjdk.jmh.annotations.Measurement;
-import org.openjdk.jmh.annotations.Mode;
-import org.openjdk.jmh.annotations.OutputTimeUnit;
-import org.openjdk.jmh.annotations.Scope;
-import org.openjdk.jmh.annotations.State;
-import org.openjdk.jmh.annotations.Warmup;
-
-/**
- *
- * @author Mirosław Hawrot
- */
-@State(Scope.Thread)
-@BenchmarkMode(Mode.AverageTime)
-@OutputTimeUnit(TimeUnit.NANOSECONDS)
-@Fork(value = 1)
-@Measurement(iterations = 6)
-@Warmup(iterations = 4)
-public class HttpRequestDecodingBenchmark {
-
-    private String headersStr = "Host: testHost\r\n"
-            + "Host2:testHost2\r\n"
-            + "\r\n";
-
-    private byte[] headersBytes;
-
-    private String reqStr = "GET /resource HTTP/1.1\r\n"
-            + headersStr;
-
-    private byte[] reqBytes;
-
-    {
-        try {
-            reqBytes = reqStr.getBytes("US-ASCII");
-            headersBytes = headersStr.getBytes("US-ASCII");
-        } catch (Exception e) {
-        }
-    }
-
-    private com.passus.ambience.protocol.http.HttpRequest ambRequest = new com.passus.ambience.protocol.http.HttpRequest();
-
-    private HttpRequestDecoder decoderStrict = new HttpRequestDecoder(true);
-
-    private HttpRequestDecoder decoderNotStrict = new HttpRequestDecoder(false);
-
-    private HttpHeadersDecoder headersDecoderNotStrict = new HttpHeadersDecoder(false);
-
-    @Benchmark
-    public int testAmbDecoder() throws Exception {
-        com.passus.ambience.protocol.http.HttpRequest ambRequest = new com.passus.ambience.protocol.http.HttpRequest();
-        return ambRequest.decode(reqBytes, 0);
-    }
-
-    //@Benchmark
-    public int testDecoder_Strict() throws Exception {
-        return decoderStrict.decode(reqBytes);
-    }
-
-    //@Benchmark
-    public int testDecoder_NotStrict() throws Exception {
-        return decoderNotStrict.decode(reqBytes);
-    }
-
-    @Benchmark
-    public int testHeadersDecoder_NotStrict() throws Exception {
-        int res = headersDecoderNotStrict.decode(headersBytes);
-        headersDecoderNotStrict.clear();
-        return res;
-    }
-
-    public static void main(String[] args) throws Exception {
-        //Options opt = new OptionsBuilder().include(HttpRequestDecodingBenchmark.class.getSimpleName() + ".*").build();
-        //new Runner(opt).run();
-
-        HttpRequestDecodingBenchmark bench = new HttpRequestDecodingBenchmark();
-        //System.out.println(bench.testAmbDecoder());
-        //System.out.println(bench.testDecoder_Strict());
-        //System.out.println(bench.testDecoder_NotStrict());
-        long start = System.currentTimeMillis();
-        for (int i = 0; i < 100000; i++) {
-            bench.testAmbDecoder();
-        }
-        System.out.println(System.currentTimeMillis() - start);
-
-        start = System.currentTimeMillis();
-        for (int i = 0; i < 100000; i++) {
-            bench.testHeadersDecoder_NotStrict();
-        }
-        System.out.println(System.currentTimeMillis() - start);
-        
-        AllocationUtils au = new AllocationUtils();
-        au.setOverheadBase(bench.headersStr.length());
-        au.checkAllocation("AmbienceDecoder", bench::testAmbDecoder);
-        au.checkAllocation("HeadersNotStrict", bench::testHeadersDecoder_NotStrict);
-        au.checkAllocation("NotStrict", bench::testDecoder_NotStrict);
-        au.checkAllocation("Strict", bench::testDecoder_Strict);
-    }
-}
--- a/stress-tester-benchmark/src/main/java/com/passus/st/protocol/http/UrlBenchmark.java	Fri Oct 06 10:03:29 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-package com.passus.st.protocol.http;
-
-import com.passus.st.data.ByteString;
-import com.passus.st.data.ByteStringImpl;
-import com.passus.utils.AllocationUtils;
-import java.util.concurrent.TimeUnit;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.annotations.BenchmarkMode;
-import org.openjdk.jmh.annotations.Fork;
-import org.openjdk.jmh.annotations.Measurement;
-import org.openjdk.jmh.annotations.Mode;
-import org.openjdk.jmh.annotations.OutputTimeUnit;
-import org.openjdk.jmh.annotations.Scope;
-import org.openjdk.jmh.annotations.State;
-import org.openjdk.jmh.annotations.Warmup;
-import org.openjdk.jmh.runner.Runner;
-import org.openjdk.jmh.runner.options.Options;
-import org.openjdk.jmh.runner.options.OptionsBuilder;
-
-/**
- *
- * @author mikolaj.podbielski
- */
-@State(Scope.Thread)
-@BenchmarkMode(Mode.AverageTime)
-@OutputTimeUnit(TimeUnit.NANOSECONDS)
-@Fork(value = 1)
-@Measurement(iterations = 10)
-@Warmup(iterations = 6)
-public class UrlBenchmark {
-
-    private String urlStr_full = "http://username:password@example.com:123/path/data?key=value&key2=value2#fragid1";
-
-    private ByteString urlByteStr_full = new ByteStringImpl(urlStr_full);
-
-    private String urlStr_simple = "http://example.com/path/";
-
-    private ByteString urlByteStr_simple = new ByteStringImpl(urlStr_simple);
-
-    @Benchmark
-    public URL stFull() throws Exception {
-        return URL.parse(urlByteStr_full);
-    }
-
-    @Benchmark
-    public URL stSimple() throws Exception {
-        return URL.parse(urlByteStr_simple);
-    }
-
-    @Benchmark
-    public java.net.URL jdkFull() throws Exception {
-        return new java.net.URL(urlStr_full);
-    }
-
-    @Benchmark
-    public java.net.URL jdkSimple() throws Exception {
-        return new java.net.URL(urlStr_simple);
-    }
-
-    public static void main(String[] args) throws Exception {
-        UrlBenchmark hub = new UrlBenchmark();
-        AllocationUtils au = new AllocationUtils();
-        au.checkAllocation(" st simple", hub::stSimple);
-        au.checkAllocation(" st full", hub::stFull);
-        au.checkAllocation("jdk simple", hub::jdkSimple);
-        au.checkAllocation("jdk full", hub::jdkFull);
-
-        Options opt = new OptionsBuilder().include(UrlBenchmark.class.getSimpleName() + ".*").build();
-        new Runner(opt).run();
-    }
-}
--- a/stress-tester-benchmark/src/main/java/com/passus/st/utils/MultiByteUtilsBenchmark.java	Fri Oct 06 10:03:29 2017 +0200
+++ b/stress-tester-benchmark/src/main/java/com/passus/st/utils/MultiByteUtilsBenchmark.java	Fri Oct 06 10:42:04 2017 +0200
@@ -1,5 +1,6 @@
 package com.passus.st.utils;
 
+import com.passus.data.DataHelper;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.IntBuffer;
@@ -26,8 +27,8 @@
 
     private final byte[] BYTES = {1, 2, 3, 45, 7, 6, 5, 4, 3, 2, 1, 1, 33, 33, 44, 44};
     private final IntBuffer ib;
-    private final MultiByteUtils mbuLe = MultiByteUtils.get(ByteOrder.LITTLE_ENDIAN);
-    private final MultiByteUtils mbuBe = MultiByteUtils.get(ByteOrder.BIG_ENDIAN);
+    private final DataHelper mbuLe = DataHelper.get(ByteOrder.LITTLE_ENDIAN);
+    private final DataHelper mbuBe = DataHelper.get(ByteOrder.BIG_ENDIAN);
     private final int I = 0x12345678;
     private final long L = 0x1234567890abcdefL;