Rick

Rick
Rick

Wednesday, December 25, 2013

From File to java.util.Map. Boon faster than Jackson

Benchmark                                   Mode Thr     Count  Sec         Mean   Mean error    Units
i.g.j.f.BoonBenchMark.actionLabel          thrpt   8         5    1   208131.360    64075.346    ops/s
i.g.j.f.JacksonASTBenchmark.actionLabel    thrpt   8         5    1   150706.530     4497.339    ops/s

25% faster Boon!

i.g.j.f.BoonBenchMark.citmCatalog          thrpt   8         5    1      613.403       34.780    ops/s
i.g.j.f.JacksonASTBenchmark.citmCatalog    thrpt           5    1      332.803       17.120    ops/s

175% faster Boon!

i.g.j.f.BoonBenchMark.medium               thrpt   8         5    1   151640.130    96788.984    ops/s
i.g.j.f.JacksonASTBenchmark.medium         thrpt           5      125208.850    31949.124    ops/s


20% faster Boon!

i.g.j.f.BoonBenchMark.menu                 thrpt   8         5    1   209612.210     5704.342    ops/s
i.g.j.f.JacksonASTBenchmark.menu           thrpt           5      186255.893    75485.346    ops/s

10% Faster Boon!

i.g.j.f.BoonBenchMark.sgml                 thrpt   8         5    1   195752.990    17465.283    ops/s
i.g.j.f.JacksonASTBenchmark.sgml           thrpt           5      169619.163    73962.962    ops/s

15% Faster Boon!

i.g.j.f.BoonBenchMark.webxml               thrpt   8         5    1   126902.333    15238.895    ops/s

i.g.j.f.JacksonASTBenchmark.webxml         thrpt           5    1    82469.550    12080.954    ops/s

30% Faster Boon!

i.g.j.f.BoonBenchMark.widget               thrpt   8         5    1   194273.057     3714.143    ops/s
i.g.j.f.JacksonASTBenchmark.widget         thrpt   8         5    1   158183.903    58280.275    ops/s

20% Faster Boon





public class JacksonASTBenchmark {


    private static final ObjectMapper JACKSON_MAPPER = new ObjectMapper();


    public static final String FILE_ACTION_LABEL = ( "data/actionLabel.json" );
    public static final String FILE_CITM_CATALOG = ( "data/citm_catalog.json" );
    public static final String FILE_MEDIUM = ( "data/medium.json" );
    public static final String FILE_MENU = ( "data/menu.json" );
    public static final String FILE_SGML = ( "data/sgml.json" );
    public static final String FILE_WEBXML = ( "data/webxml.json" );
    public static final String FILE_WIDGET = ( "data/widget.json" );


    private Object parse(String fileName) throws Exception {
            return JACKSON_MAPPER.readTree ( new File (fileName) );
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit ( TimeUnit.SECONDS)
    public void actionLabel(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_ACTION_LABEL ) );
    }


    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void citmCatalog(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_CITM_CATALOG ) );
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void medium(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_MEDIUM ) );
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void menu(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_MENU ) );
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void sgml(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_SGML ) );
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void webxml(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_WEBXML ) );
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void widget(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_WIDGET ) );
    }


}

package io.gatling.jsonbenchmark.file;

import org.boon.json.JsonParser;
import org.boon.json.JsonParserFactory;
import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.logic.BlackHole;

import java.util.Map;
import java.util.concurrent.TimeUnit;

@State
public class BoonBenchMark {

    public static final String FILE_ACTION_LABEL = ( "data/actionLabel.json" );
    public static final String FILE_CITM_CATALOG = ( "data/citm_catalog.json" );
    public static final String FILE_MEDIUM = ( "data/medium.json" );
    public static final String FILE_MENU = ( "data/menu.json" );
    public static final String FILE_SGML = ( "data/sgml.json" );
    public static final String FILE_WEBXML = ( "data/webxml.json" );
    public static final String FILE_WIDGET = ( "data/widget.json" );


    private final JsonParser parser = new JsonParserFactory ().create ();

    private Object parse(String fileName) throws Exception {
        return parser.parseFile ( Map.class, fileName);
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit ( TimeUnit.SECONDS)
    public void actionLabel(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_ACTION_LABEL ) );
    }


    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void citmCatalog(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_CITM_CATALOG ) );
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void medium(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_MEDIUM ) );
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void menu(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_MENU ) );
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void sgml(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_SGML ) );
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void webxml(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_WEBXML ) );
    }

    @GenerateMicroBenchmark
    @OutputTimeUnit(TimeUnit.SECONDS)
    public void widget(BlackHole bh) throws Exception {
        bh.consume( parse( FILE_WIDGET ) );
    }

}

No comments:

Post a Comment

Kafka and Cassandra support, training for AWS EC2 Cassandra 3.0 Training