Browse Source

Merge branch 'master' into hipe

Takeru Ohta 11 years ago
parent
commit
d2323a51fe
2 changed files with 62 additions and 6 deletions
  1. 58 2
      README.md
  2. 4 4
      src/jsone.erl

+ 58 - 2
README.md

@@ -3,6 +3,7 @@ jsone (0.2.3)
 
 An Erlang library for encoding, decoding [JSON](http://json.org/index.html) data.
 
+
 Features
 --------
 - Provides simple encode/decode function only
@@ -11,7 +12,7 @@ Features
 - Pure Erlang
 - Highly Efficient
   - Maybe one of the fastest JSON library (except those which are implemented in NIF)
-      - TODO: benchmark result
+      - See [Benchmark](#benchmark)
   - Decode function is written in continuation-passing style(CPS)
       - CPS facilitates application of 'creation of sub binary delayed' optimization
       - See also [Erlang Efficiency Guide](http://www.erlang.org/doc/efficiency_guide/binaryhandling.html)
@@ -94,7 +95,7 @@ Usage Example
 ```
 
 
-Data Mapping (Erlang<=> JSON)
+Data Mapping (Erlang <=> JSON)
 -------------------------------
 
 |         | Erlang                       | JSON            |
@@ -110,3 +111,58 @@ Data Mapping (Erlangの<=> JSON)
 API
 ---
 See [EDoc Document](doc/jsone.md)
+
+
+Benchmark
+---------
+
+### Environment/Method
+
+- OS: CentOS 6.5
+- CPU: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz (x8)
+- Erlang/OTP: R17.1
+- Benchmark Tool: [erl_json_test](https://github.com/si14/erl_json_test/tree/7ae5a254943ce3e5d9e4d5eb9cd2e86b92ce8e83)
+- CompileOption: [native, {hipe, [o3]}]
+
+### Target
+
+- [jiffy-0.11.3](https://github.com/davisp/jiffy/tree/0.11.3) (NIF)
+- [jsone-v0.2.3](https://github.com/sile/jsone/tree/0.2.3-hipe) (HiPE)
+- [jsonerl](https://github.com/lambder/jsonerl/tree/9720df66052dfc66c9935d954061eda56f81a6f2) (HiPE)
+- [jsonx](https://github.com/iskra/jsonx/tree/9c95948c6835827ed61a9506ae4a9aba61acf335) (NIF)
+- [jsx-v2.0.1](https://github.com/talentdeficit/jsx/tree/v2.0.1) (HiPE)
+- [mochijson2](https://github.com/bjnortier/mochijson2/tree/3663fb01fd98958181adc2d1300c7bfa553e1434) (HiPE)
+- [yawsjson2](https://github.com/spawnproc/yawsjson2/tree/863b7476b4bf7615b578316670c3bd7f04e0048f) (HiPE)
+
+### Decode Result
+
+- column: module name
+- row: data size (bytes)
+- cell: elapsed time (micro seconds)
+
+|                   | jiffy | jsone | jsonerl | jsonx |  jsx  | mochijson2 | yawsjson2 | 
+|------------------:|------:|------:|--------:|------:|------:|-----------:|----------:|
+| 559 (1x)          | 12    | 11    | 61      | 7     | 50    | 28         | 37        |
+| 1583 (3x)         | 24    | 25    | 66      | 15    | 134   | 68         | 84        |
+| 4637 (9x)         | 65    | 86    | 178     | 36    | 410   | 186        | 311       |
+| 13914 (27x)       | 189   | 271   | 533     | 109   | 1466  | 550        | 582       |
+| 41542 (81x)       | 525   | 813   | 1578    | 299   | 4684  | 1599       | 1939      |
+| 124726 (243x)     | 1549  | 2406  | 4709    | 852   | 14562 | 4799       | 6123      |
+
+### Encode Result
+
+- column: module name
+- row: data size (bytes)
+- cell: elapsed time (micro seconds)
+
+|                   | jiffy | jsone | jsonerl | jsonx |  jsx  | mochijson2 | yawsjson2 | 
+|------------------:|------:|------:|--------:|------:|------:|-----------:|----------:|
+| 559 (1x)          | 14    | 19    | 21      | 8     | 83    | 19         | 15        |
+| 1583 (3x)         | 29    | 49    | 65      | 14    | 228   | 61         | 42        |
+| 4637 (9x)         | 77    | 133   | 229     | 36    | 638   | 225        | 161       |
+| 13914 (27x)       | 215   | 393   | 737     | 101   | 1993  | 664        | 435       |
+| 41542 (81x)       | 621   | 1172  | 2058    | 300   | 6237  | 2310       | 1192      |
+| 124726 (243x)     | 1830  | 3968  | 5842    | 828   | 17032 | 6979       | 5266      |
+
+
+

+ 4 - 4
src/jsone.erl

@@ -65,7 +65,7 @@
 %% ```
 %% > jsone:decode(<<"1">>).
 %% 1
-%%
+%% 
 %% > jsone:decode(<<"wrong json">>).
 %% ** exception error: bad argument
 %%     in function  jsone_decode:number_integer_part/4
@@ -87,7 +87,7 @@ decode(Json) ->
 %% ```
 %% > jsone:try_decode(<<"[1,2,3] \"next value\"">>).
 %% {ok,[1,2,3],<<" \"next value\"">>}
-%%
+%%  
 %% > jsone:try_decode(<<"wrong json">>).
 %% {error,{badarg,[{jsone_decode,number_integer_part,
 %%                               [<<"wrong json">>,1,[],<<>>],
@@ -104,7 +104,7 @@ try_decode(Json) ->
 %% ```
 %% > jsone:encode([1, null, 2]).
 %% <<"[1,null,2]">>
-%%
+%%  
 %% > jsone:encode([1, hoge, 2]).  % 'hoge' atom is not a json value
 %% ** exception error: bad argument
 %%      in function  jsone_encode:value/3
@@ -126,7 +126,7 @@ encode(JsonValue) ->
 %% ```
 %% > jsone:try_encode([1, null, 2]).
 %% {ok,<<"[1,null,2]">>}
-%%
+%%  
 %% > jsone:try_encode([1, hoge, 2]).  % 'hoge' atom is not a json value
 %% {error,{badarg,[{jsone_encode,value,
 %%                               [hoge,[{array_values,[2]}],<<"[1,">>],