@Test
public void testRegexSpeed() {

    incoming.put("passAllAddresses", true);
    Map<String, Object> regexParser = new LinkedHashMap<>();
    String pattern = "<(\\d{1,3})>([1-9]\\d{0,2}) (?:(-)|(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\."
            + "\\d{1,6})?(?:Z|[-+]\\d{2}:\\d{2}))) (-|[!-~]{1,255}) (-|[!-~]{1,48}) (-|[!-~]{1,128}) (-|[!-~]{1,32}"
            + ") (?:(-)|((?:\\[[!-~&&[^ =\\]]]{1,32}(?: [!-~&&[^ =\\]]]{1,32}=\"(?:[\\u0000-\\uffff&&[^\"\\\\\\]]]|"
            + "(?:\\\\[\\\\\"\\]]))*\")*])+))(?: (?:((?!\\xef\\xbb\\xbf).*)|(?:\\xef\\xbb\\xbf([\\u0000-\\uffff]*))"
            + "))?";
    regexParser.put("pattern", pattern);
    String[] locations = {"priority", "version", "noTimestamp", "timestamp", "hostName", "appName", "processId", 
                          "messageId", "noStructuredData", "structuredData", "standardMessage", "utfMessage"};
    regexParser.put("locations", Arrays.asList(locations));
    incoming.put("regexParser", regexParser);
    String testMessage = "<0>198 2018-07-23T15:26:20-07:00 remote iApp user branch [name] Here be a message for ya!";
    byte[] packetBytes = testMessage.getBytes();
    DatagramPacket packet= new DatagramPacket(packetBytes, packetBytes.length);
    
    assert Pattern.matches(pattern, testMessage);
    
    nHandler = new UDPNotificationHandler(incoming, fakeClient);
    nHandler.handleMessage(packet);
    int runCount = 100 * 1000;
    long currentTime = System.currentTimeMillis();
    
    for (int i = 0; i < runCount; i ++) {
        packetBytes = testMessage.getBytes();
        packetBytes[1] = (byte) ((i & 7) + 48);
        packet = new DatagramPacket(packetBytes, packetBytes.length);
        nHandler.handleMessage(packet);
    }
    
    long timeTaken = System.currentTimeMillis() - currentTime;
    
    
    System.out.println("Time taken for " + runCount + " messages was " + timeTaken + " ms");
    System.out.println("This is " + ((double)timeTaken) / runCount + " ms per message and "
                + (int) (1.0 / timeTaken * runCount) + " thousand messages per second");
}