penanda aras fastjson
Dalam fastjson-1.2.11, prestasi penyirian telah dipertingkatkan dengan sangat baik, dan prestasi penyahserilan juga telah dipertingkatkan, jadi kami melakukan ujian perbandingan prestasi dengan perpustakaan bersiri lain.
Senario ujian
menerima pakai ujian yang diiktiraf oleh pelbagai pengarang perpustakaan bersiri, daripada https://github.com/eihay/jvm-serializers, kerana ujian rasmi masih belum menggunakan versi terkini. fastjson, jadi saya bercabang dan mengubah suai untuk menggunakan API terkini, kodnya ada di sinihttps://github.com/wenshao/jvm-serializers/tree/fastjson-1.2.11
Jalankan ujian
git clone https://github.com/wenshao/jvm-serializers.git cd jvm-serializers/tpc make ./run-bench.sh json/jackson+afterburner/databind,json/fastjson/databind,json/fastjson_array/databind,protobuf,json/jackson/databind,msgpack/databind
Struktur kelas
Adegan eihay, ada tiga kelas, struktur kelas adalah seperti berikut
class MediaContent { public Media media; public Image[] images; } class Media implements java.io.Serializable { public enum Player { JAVA, FLASH } public String uri; public String title; // Can be unset. public int width; public int height; public String format; public long duration; public long size; public boolean hasBitrate; public List<String> persons; public Player player; public String copyright; // Can be unset. } class Image { public enum Size { SMALL, LARGE } public String uri; public String title; // Can be null public int width; public int height; public Size size; }
Lihat kod terperinci di sini:
- https://github.com/wenshao/jvm-serializers/blob/fastjson-1.2.11/tpc/src/data/media/MediaContent.java
- https: //github.com/wenshao/jvm-serializers/blob/fastjson-1.2.11/tpc/src/data/media/Media.java
- https://github.com/wenshao/jvm-serializers/blob / fastjson-1.2.11/tpc/src/data/media/Image.java
Data ujian
Senario ujian ialah media.1.cks, dan json yang sepadan adalah seperti berikut
{"images":[{"height":768,"size":"LARGE","title":"Javaone Keynote","uri":"http://javaone.com/keynote_large.jpg","width":1024},{"height":240,"size":"SMALL","title":"Javaone Keynote","uri":"http://javaone.com/keynote_small.jpg","width":320}],"media":{"bitrate":262144,"duration":18000000,"format":"video/mpg4","height":480,"persons":["Bill Gates","Steve Jobs"],"player":"JAVA","size":58982400,"title":"Javaone Keynote","uri":"http://javaone.com/keynote.mpg","width":640}}fastjson , jika mod BeanToArray didayakan, json yang sepadan ialah:
[[[768,1,"Javaone Keynote","http://javaone.com/keynote_large.jpg",1024],[240,0,"Javaone Keynote","http://javaone.com/keynote_small.jpg",320]],[262144,null,18000000,"video/mpg4",480,["Bill Gates","Steve Jobs"],0,58982400,"Javaone Keynote","http://javaone.com/keynote.mpg",640]]