快速JSON序列化 Easyjson

码农软件 · 软件分类 · 其他开发相关 · 2019-10-18 16:28:52

软件介绍

Easyjson用于序列化JSON数据,采用Go语言编写,而不是通过使用反射生成编组代码。一个库的目的之一是使所生成的代码足够简单,使得它可以容易地优化或固定。另一个目标是为用户提供不可定制的“encoding/json”,如产生snake_case名称或启用默认“omitempty“生成代码。

用法:

go get github.com/mailru/easyjson/...
easyjson -all <file>.go

这将利用编组/解组方法结构生成<file>_easyjson.go

限制:

  • The library is at an early stage, there are likely to be some bugs and some features of 'encoding/json' may not be supported. Please report such cases, so that they may be fixed sooner.

  • Unsafe package is used by the code. While a non-unsafe version of easyjson can be made in the future, using unsafe package simplifies a lot of code by allowing to use 'switch' for filling out structs and working around limitations of standard functions like 'strconv.ParseInt'.

  • Floats are currently formatted with default precision for 'strconv' package. It is obvious that it is not always the correct way to handle it, but there aren't enough use-cases for floats at hand to do anything better.

  • During parsing, parts of JSON that are skipped over are not syntactically validated more than required to skip matching parentheses.

  • No true streaming support for encoding/decoding. For many use-cases and protocols, data length is typically known on input and needs to be known before sending the data.

解析:

libjson sizeMB/sallocs/opB/op
standardregular2221810229
standardsmall9.714720
-------------------------------------------
easyjsonregular1251289794
easyjsonsmall673128
-------------------------------------------
ffjsonregular661419985
ffjsonsmall17.610488
-------------------------------------------
codecregular5543419299
codecsmall297336
-------------------------------------------
ujsonregular103N/AN/A

编组,one goroutine

libjson sizeMB/sallocs/opB/op
standardregular75923256
standardsmall323328
standardlarge80171.2M
---------------------------------------------
easyjsonregular213910260
easyjson*regular2638742
easyjsonsmall1251128
easyjsonlarge21233490k
easyjson*large262252879
---------------------------------------------
ffjsonregular12215321340
ffjson**regular1461524897
ffjsonsmall365384
ffjson**small644128
ffjsonlarge1347317818k
ffjson**large1257320827k
---------------------------------------------
codecregular801733601
codec***regular10891153
codecsmall423304
codec***small56148
codeclarge734832.5M
codec***large10345166007
---------------------------------------------
ujsonregular92N/AN/A

编组,并发

libjson sizeMB/sallocs/opB/op
standardregular252923257
standardsmall1243328
standardlarge289171.2M
----------------------------------------------
easyjsonregular792910597
easyjson*regular17488779
easyjsonsmall3331128
easyjsonlarge71836548k
easyjson*large2134254957
---------------------------------------------
ffjsonregular30115321629
ffjson**regular7071525148
ffjsonsmall625384
ffjson**small2824128
ffjsonlarge43873301.0M
ffjson**large1317319820k
---------------------------------------------
codecregular1831733603
codec***regular67191157
codecsmall1473304
codec***small299148
codeclarge1904832.5M
codec***large75245177574


本文地址:https://codercto.com/soft/d/17038.html

算法竞赛入门经典

算法竞赛入门经典

刘汝佳、陈锋 / 2012-10 / 52.80元

《算法竞赛入门经典:训练指南》是《算法竞赛入门经典》的重要补充,旨在补充原书中没有涉及或者讲解得不够详细的内容,从而构建一个较完整的知识体系,并且用大量有针对性的题目,让抽象复杂的算法和数学具体化、实用化。《算法竞赛入门经典:训练指南》共6章,分别为算法设计基础、数学基础、实用数据结构、几何问题、图论算法与模型和更多算法专题,全书通过近200道例题深入浅出地介绍了上述领域的各个知识点、经典思维方式......一起来看看 《算法竞赛入门经典》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具