package org.cubeengine.dirigent.perf;

import org.cubeengine.dirigent.parser.Tokenizer;

public class SimpleColdToHot
{

    public static void main(String[] args)
    {
        String msg = "text and a macro {1:name#with index and comment:and parameter=with value:multiple:and one=more} more text";
        long start, delta;
        long values = 0;
        double avg = 0;
        int printAt = 1;

        for (int i = 0; i < 100000000; i++)
        {
            start = System.nanoTime();
            Tokenizer.tokenize(msg);
            delta = System.nanoTime() - start;
            avg = (avg * values + delta) / (values + 1);
            values++;
            if (i == printAt - 1 || i < 10)
            {
                System.out.println("Time at " + (i + 1) + ": " + (avg / 1000d) + "µs");
                values = 0;
                avg = 0;
                if (i == printAt - 1) printAt *= 10;
            }
        }
    }
}

@@ -43,131 +43,1184 @@
 ort 
-org.cubeengine.dirigent.parser.Tokenizer;%0A%0Apublic class SimpleColdToHot%0A%7B%0A%0A    public static void main(String%5B%5D args)%0A    %7B
+java.util.List;%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0Aimport org.cubeengine.dirigent.formatter.argument.Argument;%0Aimport org.cubeengine.dirigent.formatter.argument.Parameter;%0Aimport org.cubeengine.dirigent.formatter.argument.Value;%0Aimport org.cubeengine.dirigent.parser.Tokenizer;%0Aimport org.cubeengine.dirigent.parser.token.CompleteMacro;%0Aimport org.cubeengine.dirigent.parser.token.DefaultMacro;%0Aimport org.cubeengine.dirigent.parser.token.Indexed;%0Aimport org.cubeengine.dirigent.parser.token.IndexedDefaultMacro;%0Aimport org.cubeengine.dirigent.parser.token.NamedMacro;%0Aimport org.cubeengine.dirigent.parser.token.Token;%0A%0Aimport static java.util.Arrays.asList;%0A%0Apublic class SimpleColdToHot%0A%7B%0A%0A    public static void main(String%5B%5D args)%0A    %7B%0A        List%3CClass%3C?%3E%3E classes = asList(Tokenizer.class, Token.class, DefaultMacro.class, NamedMacro.class,%0A                                        IndexedDefaultMacro.class, Indexed.class, CompleteMacro.class, Argument.class,%0A                                        Value.class, Parameter.class, Pattern.class, Matcher.class);%0A        System.out.println(%22Classes:%22);%0A        System.out.println(classes);%0A
 %0A   

load all classes before running tests