public void runNativeComparison(int iterations) {
        oul("Running native expression...");
        MapContext arguments=new MapContext();
        arguments.put("one",1d);

        out("  warming up...");
        double nativeTotal=0;
        for (int i=0; i<iterations/5; i++) {
            arguments.put("i",(double)i);
            nativeTotal+=nativeExpression(arguments);
        }
        oul("done");

        out("  running " + iterations + " iterations...");
        long startTime=System.currentTimeMillis();
        for (int i=0; i<iterations; i++) {
            arguments.put("i",(double)i);
            nativeTotal+=nativeExpression(arguments);
        }
        long nativeTotalTime=System.currentTimeMillis()-startTime;
        oul("done");
        oul("  Total time running native:     " + nativeTotalTime + " ms (" + iterations/nativeTotalTime + " expressions/ms)");

        oul("Running ranking expression...");
        RankingExpression expression;
        try {
            expression=new RankingExpression(comparisonExpression);
        }
        catch (ParseException e) {
            throw new RuntimeException(e);
        }
        out("  warming up...");
        double rankingTotal=0;
        for (int i=0; i<iterations/5; i++) {
            arguments.put("i",(double)i);
            rankingTotal+=expression.evaluate(arguments).asDouble();
        }
        oul("done");

        out("  running " + iterations + " iterations...");
        startTime=System.currentTimeMillis();
        for (int i=0; i<iterations; i++) {
            arguments.put("i",(double)i);
            rankingTotal+=expression.evaluate(arguments).asDouble();
        }
        long rankingTotalTime=System.currentTimeMillis()-startTime;
        if (rankingTotal!=nativeTotal)
            throw new IllegalStateException("Expressions are not the same, native: " + nativeTotal + " rankingExpression: " + rankingTotal);
        oul("done");
        oul("  Total time running expression: " + rankingTotalTime + " ms (" + iterations/rankingTotalTime + " expressions/ms)");
        oul("Expression % of max possible speed: " + ((int)((100*nativeTotalTime)/rankingTotalTime)) + " %");
    }
Two small benchmarks of ranking expression evaluation

@author bratseth
searchlib/src/test/java/com/yahoo/searchlib/rankingexpression/evaluation/EvaluationBenchmark.java