Browse Source

Update README.md

Takeru Ohta 4 years ago
parent
commit
0d910099c1
3 changed files with 43 additions and 333 deletions
  1. 0 283
      BENCHMARK.md
  2. 43 49
      README.md
  3. 0 1
      benchmark/README.md

+ 0 - 283
BENCHMARK.md

@@ -1,283 +0,0 @@
-Benchmark
-=========
-
-Environment
------------
-
-- OS: Ubuntu-16.04
-- CPU: Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz (x2)
-- Erlang: OTP-19.0.2 ([package link](https://packages.erlang-solutions.com/erlang/esl-erlang/FLAVOUR_1_general/esl-erlang_19.0.2-1~ubuntu~xenial_amd64.deb))
-- Benchmark: [The benchmark of poison(v2.2.0)](https://github.com/devinus/poison/blob/2.2.0/README.md#benchmarking)
-
-Benchmarks
-----------
-
-To execute following commands, the [Elixir](http://elixir-lang.org/) is required.
-
-```sh
-###
-### Downloads poison
-###
-$ git clone https://github.com/devinus/poison
-$ cd poison
-$ git checkout 2.2.0
-
-
-###
-### Benchmark: Non HiPE
-###
-$ patch -p1 < jsone.patch
-$ mix deps.get
-$ MIX_ENV=bench mix compile
-$ MIX_ENV=bench mix bench
-Settings:
-duration:      1.0 s
-... abbrev ...
-Finished in 96.87 seconds
-
-## EncoderBench
-structs (Poison)               500000   6.51 µs/op
-maps (jiffy)                   500000   7.23 µs/op
-maps (jsone)                   100000   10.64 µs/op
-maps (Poison)                  100000   13.58 µs/op
-structs (Jazz)                 100000   13.96 µs/op
-structs (JSX)                  100000   15.78 µs/op
-maps (Jazz)                    100000   19.30 µs/op
-maps (JSX)                      50000   29.28 µs/op
-strings (jiffy)                 20000   98.80 µs/op
-lists (Poison)                  10000   109.30 µs/op
-string escaping (jiffy)         10000   144.01 µs/op
-lists (jsone)                   10000   157.39 µs/op
-lists (Jazz)                    10000   201.82 µs/op
-lists (jiffy)                   10000   210.40 µs/op
-strings (JSX)                   10000   262.18 µs/op
-lists (JSX)                      5000   357.25 µs/op
-strings (Jazz)                   5000   399.89 µs/op
-jiffy                            5000   408.03 µs/op
-strings (Poison)                 5000   416.78 µs/op
-jiffy (pretty)                   5000   420.94 µs/op
-strings (jsone)                  5000   595.63 µs/op
-string escaping (jsone)          2000   732.44 µs/op
-string escaping (Jazz)           1000   1197.06 µs/op
-string escaping (Poison)         1000   1318.82 µs/op
-string escaping (JSX)            1000   1324.04 µs/op
-Poison                           1000   1447.71 µs/op
-Poison (pretty)                  1000   1534.74 µs/op
-jsone                            1000   1556.85 µs/op
-jsone (pretty)                   1000   1686.55 µs/op
-Jazz                             1000   1824.05 µs/op
-Jazz (pretty)                    1000   2041.22 µs/op
-JSX                              1000   2184.59 µs/op
-JSX (pretty)                      500   5533.04 µs/op
-
-## ParserBench
-UTF-8 unescaping (jiffy)        50000   63.01 µs/op
-UTF-8 unescaping (Poison)       10000   249.70 µs/op
-UTF-8 unescaping (JSX)          10000   281.84 µs/op
-UTF-8 unescaping (jsone)         5000   399.38 µs/op
-jiffy                            5000   544.84 µs/op
-jsone                            1000   1364.38 µs/op
-Poison                           1000   1401.35 µs/op
-JSX                              1000   1844.55 µs/op
-
-
-###
-### Benchmark: HiPE
-###
-$ mix clean --deps && find . -name '*.beam' | xargs rm
-$ ERL_COMPILER_OPTIONS="native" MIX_ENV=bench mix compile
-$ MIX_ENV=bench mix bench
-Settings:
-duration:      1.0 s
-... abbrev ...
-Finished in 102.75 seconds
-
-## EncoderBench
-maps (jsone)                   500000   6.12 µs/op
-structs (Poison)               500000   6.49 µs/op
-maps (jiffy)                   500000   7.69 µs/op
-maps (Poison)                  100000   12.32 µs/op
-structs (JSX)                  100000   13.51 µs/op
-structs (Jazz)                 100000   15.06 µs/op
-maps (Jazz)                    100000   22.90 µs/op
-maps (JSX)                     100000   27.03 µs/op
-lists (jsone)                   50000   69.93 µs/op
-lists (Poison)                  20000   79.04 µs/op
-strings (jiffy)                 20000   96.67 µs/op
-strings (Poison)                10000   142.43 µs/op
-string escaping (jiffy)         10000   146.85 µs/op
-strings (JSX)                   10000   179.96 µs/op
-lists (jiffy)                   10000   207.75 µs/op
-lists (Jazz)                    10000   229.95 µs/op
-lists (JSX)                     10000   278.01 µs/op
-strings (Jazz)                   5000   310.10 µs/op
-string escaping (jsone)          5000   317.10 µs/op
-strings (jsone)                  5000   321.69 µs/op
-jiffy                            5000   409.73 µs/op
-jiffy (pretty)                   5000   419.55 µs/op
-jsone                            5000   664.34 µs/op
-jsone (pretty)                   5000   724.28 µs/op
-string escaping (JSX)            2000   767.67 µs/op
-Poison                           2000   806.24 µs/op
-Poison (pretty)                  2000   844.76 µs/op
-string escaping (Poison)         1000   1277.54 µs/op
-string escaping (Jazz)           1000   1311.85 µs/op
-Jazz                             1000   1630.21 µs/op
-JSX                              1000   1777.62 µs/op
-Jazz (pretty)                    1000   1888.71 µs/op
-JSX (pretty)                      500   4872.34 µs/op
-
-## ParserBench
-UTF-8 unescaping (jiffy)        50000   62.42 µs/op
-UTF-8 unescaping (jsone)        20000   92.63 µs/op
-UTF-8 unescaping (Poison)       10000   118.97 µs/op
-UTF-8 unescaping (JSX)          10000   172.07 µs/op
-jiffy                            5000   542.77 µs/op
-jsone                            5000   561.15 µs/op
-Poison                           5000   751.36 µs/op
-JSX                              1000   1435.10 µs/op
-```
-
-Libraries Version
------------------
-
-mix.lock:
-```elixir
-%{"benchfella": {:hex, :benchfella, "0.3.2"},
-  "earmark": {:hex, :earmark, "0.2.1"},
-  "ex_doc": {:hex, :ex_doc, "0.12.0"},
-  "exjsx": {:git, "https://github.com/talentdeficit/exjsx.git", "202b2ee1b274511973de60e9fdfed218d3b5eecc", []},
-  "jazz": {:git, "https://github.com/meh/jazz.git", "49f335492aca5516495199dd81dd18b845ebaa69", []},
-  "jiffy": {:git, "https://github.com/davisp/jiffy.git", "330f41c486cf949707eb494b855634df324a6d92", []},
-  "jsone": {:hex, :jsone, "1.2.6"},
-  "jsx": {:hex, :jsx, "2.6.2"}}
-```
-
-Patches
--------
-
-jsone.patch:
-```patch
-diff --git a/bench/encoder_bench.exs b/bench/encoder_bench.exs
-index cf40dcd..3453a2d 100644
---- a/bench/encoder_bench.exs
-+++ b/bench/encoder_bench.exs
-@@ -10,6 +10,10 @@ defmodule EncoderBench do
-     :jiffy.encode(list)
-   end
-
-+  bench "lists (jsone)", [list: gen_list] do
-+    :jsone.encode(list)
-+  end
-+
-   bench "lists (JSX)", [list: gen_list] do
-     JSX.encode!(list)
-   end
-@@ -27,6 +31,10 @@ defmodule EncoderBench do
-     :jiffy.encode(map)
-   end
-
-+  bench "maps (jsone)", [map: gen_map] do
-+    :jsone.encode(map)
-+  end
-+
-   bench "maps (JSX)", [map: gen_map] do
-     JSX.encode!(map)
-   end
-@@ -44,6 +52,10 @@ defmodule EncoderBench do
-     :jiffy.encode(string)
-   end
-
-+  bench "strings (jsone)", [string: gen_string] do
-+    :jsone.encode(string, [:native_utf8])
-+  end
-+
-   bench "strings (JSX)", [string: gen_string] do
-     JSX.encode!(string)
-   end
-@@ -61,6 +73,10 @@ defmodule EncoderBench do
-     :jiffy.encode(string, [:uescape])
-   end
-
-+  bench "string escaping (jsone)", [string: gen_string] do
-+    :jsone.encode(string)
-+  end
-+
-   bench "string escaping (JSX)", [string: gen_string] do
-     JSX.encode!(string, [:uescape])
-   end
-@@ -90,6 +106,10 @@ defmodule EncoderBench do
-     :jiffy.encode(data)
-   end
-
-+  bench "jsone", [data: gen_data] do
-+    :jsone.encode(data)
-+  end
-+
-   bench "JSX", [data: gen_data] do
-     JSX.encode!(data)
-   end
-@@ -106,6 +126,10 @@ defmodule EncoderBench do
-     :jiffy.encode(data, [:pretty])
-   end
-
-+  bench "jsone (pretty)", [data: gen_data] do
-+    :jsone.encode(data, [{:indent, 1}, {:space, 2}])
-+  end
-+
-   bench "JSX (pretty)", [data: gen_data] do
-     JSX.encode!(data) |> JSX.prettify!
-   end
-diff --git a/bench/parser_bench.exs b/bench/parser_bench.exs
-index a71fbff..114f226 100644
---- a/bench/parser_bench.exs
-+++ b/bench/parser_bench.exs
-@@ -12,6 +12,10 @@ defmodule ParserBench do
-     :jiffy.decode(json, [:return_maps])
-   end
-
-+  bench "jsone", [json: gen_json] do
-+    :jsone.decode(json)
-+  end
-+
-   bench "JSX", [json: gen_json] do
-     JSX.decode!(json, [:strict])
-   end
-@@ -25,6 +29,10 @@ defmodule ParserBench do
-     :jiffy.decode(utf8)
-   end
-
-+  bench "UTF-8 unescaping (jsone)", [utf8: gen_utf8] do
-+    :jsone.decode(utf8)
-+  end
-+
-   bench "UTF-8 unescaping (JSX)", [utf8: gen_utf8] do
-     JSX.decode!(utf8, [:strict])
-   end
-diff --git a/config/config.exs b/config/config.exs
-index 1240a78..d176e11 100644
---- a/config/config.exs
-+++ b/config/config.exs
-@@ -15,7 +15,8 @@ use Mix.Config
- #       format: "$time $metadata[$level] $message\n"
-
- config :poison,
--  native: :erlang.system_info(:hipe_architecture) != :undefined
-+#  native: :erlang.system_info(:hipe_architecture) != :undefined
-+  native: false
-
- # It is also possible to import configuration files, relative to this
- # directory. For example, you can emulate configuration per environment
-diff --git a/mix.exs b/mix.exs
-index 89a8c10..ac2f53e 100644
---- a/mix.exs
-+++ b/mix.exs
-@@ -33,6 +33,7 @@ defmodule Poison.Mixfile do
-     [{:earmark, "~> 0.2", only: :docs},
-      {:ex_doc, "~> 0.11", only: :docs},
-      {:benchfella, "~> 0.3", only: :bench},
-+     {:jsone, "~> 1.2.6", only: :bench},
-      {:jiffy, github: "davisp/jiffy", only: :bench},
-      {:exjsx, github: "talentdeficit/exjsx", only: :bench},
-      {:jazz, github: "meh/jazz", only: :bench}]
-```

+ 43 - 49
README.md

@@ -17,7 +17,7 @@ Features
 - Pure Erlang
 - Highly Efficient
   - Maybe one of the fastest JSON library (except those which are implemented in NIF)
-      - See [Benchmark](#benchmark)
+      - See [Benchmark](benchmark/README.md)
   - 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)
@@ -228,55 +228,49 @@ Benchmark
 
 The results of [poison](https://github.com/devinus/poison) benchmarking.
 
-See the [BENCHMARK.md](BENCHMARK.md) file for more information.
+See the [benchmark/README.md](benchmark/README.md) file for more information.
+
+### Encoding (Unit: IPS=inputs per second)
+
+| Input data \ Library | Jason      | jiffy       | JSON*  | jsone      | JSX    | Poison | Tiny   |
+|----------------------|-----------:|------------:|-------:|-----------:|-------:|-------:|-------:|
+| [Blockchain]         |     2.77 K |  **4.55 K** | 0.45 K | 1.44 K (3) | 0.60 K | 1.30 K | 0.99 K |
+| [Giphy]              |     230.65 |  **487.67** |  47.73 | 114.57 (4) |  44.97 | 114.57 | 113.59 |
+| [GitHub]             |     880.03 | **1566.67** | 139.79 | 300.26 (5) |  99.68 | 424.75 | 455.07 |
+| [GovTrack]           |       6.57 |   **24.92** |   2.33 |   5.35 (5) |   2.65 |   7.06 |   7.86 |
+| [Issue 90]           |  **22.80** |       21.92 |   0.77 |  14.30 (3) |   5.33 |  12.60 |  12.95 |
+| [JSON Generateor]    |     200.40 |  **606.81** |  42.45 | 147.12 (4) |  68.73 | 187.95 | 123.93 |
+| [Pokedex]            |     209.51 |  **776.67** |  62.60 | 161.45 (4) |  69.87 | 190.93 | 125.16 |
+| [UTF-8 unescaped]    |     626.25 | **6644.53** |1167.89 | 582.41 (4) | 273.48 | 401.44 | 220.14 |
+
+\* Only `JSON` didn't escape non-ASCII unicode characters on the encoding
+
+[Blockchain]: https://github.com/devinus/poison/blob/4.0.1/bench/data/blockchain.json
+[Giphy]: https://github.com/devinus/poison/blob/4.0.1/bench/data/giphy.json
+[GitHub]: https://github.com/devinus/poison/blob/4.0.1/bench/data/github.json
+[GovTrack]: https://github.com/devinus/poison/blob/4.0.1/bench/data/govtrack.json
+[Issue 90]: https://github.com/devinus/poison/blob/4.0.1/bench/data/issue-90.json
+[JSON Generateor]: https://github.com/devinus/poison/blob/4.0.1/bench/data/json-generator.json
+[JSON Generateor (Pretty)]: https://github.com/devinus/poison/blob/4.0.1/bench/data/json-generator-pretty.json
+[Pokedex]: https://github.com/devinus/poison/blob/4.0.1/bench/data/pokedex.json
+[UTF-8 escaped]: https://github.com/devinus/poison/blob/4.0.1/bench/data/utf-8-escaped.json
+[UTF-8 unescaped]: https://github.com/devinus/poison/blob/4.0.1/bench/data/utf-8-unescaped.json
+
+### Decoding (Unit: IPS=inputs per second)
+
+| Input data \ Library       | Jason      | jiffy       | JSON   | jsone      | JSX    | Poison | Tiny   |
+|----------------------------|-----------:|------------:|-------:|-----------:|-------:|-------:|-------:|
+| [Blockchain]               | **2.75 K** |      2.62 K | 0.35 K | 2.21 K (3) | 0.89 K | 1.32 K | 1.49 K |
+| [Giphy]                    |     212.18 |  **243.45** |  35.67 | 109.11 (5) |  64.32 | 110.76 | 114.54 |
+| [GitHub]                   |     973.41 | **1052.94** | 137.02 | 662.39 (3) | 271.97 | 438.79 | 542.67 |
+| [GovTrack]                 |  **10.77** |        8.32 |   0.80 |   5.08 (3) |   2.81 |   3.58 |   3.65 |
+| [Issue 90]                 |      17.85 |   **41.16** |   0.88 |  10.79 (5) |   6.02 |  13.63 |  14.03 |
+| [JSON Generateor]          | **320.79** |      243.93 |  25.16 | 184.23 (3) | 111.24 | 135.47 | 139.78 |
+| [JSON Generateor (Pretty)] | **273.57** |      205.09 |  25.04 | 158.82 (3) |  97.93 | 123.31 | 136.65 |
+| [Pokedex]                  | **527.63** |      285.43 |  33.70 | 245.36 (3) | 140.90 | 172.45 | 152.59 |
+| [UTF-8 escaped]            |    1224.48 | **7923.08** | 326.43 | 573.70 (4) | 550.36 | 918.21 | 520.31 |
+| [UTF-8 unescaped]          |     5.56 K | **12.54 K** | 1.35 K | 5.09 K (3) | 3.30 K | 4.39 K | 1.46 K |
 
-### EncoderBench Result
-
-__Non HiPE__:
-
-|                  | jiffy        | jsone             | poison        | jazz          | jsx           |
-|:-----------------|-------------:|------------------:|--------------:|--------------:|--------------:|
-| maps             |   7.23 μs/op |   10.64 μs/op (2) |   13.58 μs/op |   19.30 μs/op |   29.28 μs/op |
-| lists            | 210.40 μs/op |  157.39 μs/op (3) |  109.30 μs/op |  201.82 μs/op |  357.25 μs/op |
-| strings*         |  98.80 μs/op |  595.63 μs/op (5) |  416.78 μs/op |  399.89 μs/op |  262.18 μs/op |
-| string escaping* | 144.01 μs/op |  732.44 μs/op (2) | 1318.82 μs/op | 1197.06 μs/op | 1324.04 μs/op |
-| large value**    | 408.03 μs/op | 1556.85 μs/op (3) | 1447.71 μs/op | 1824.05 μs/op | 2184.59 μs/op |
-| pretty print**   | 420.94 μs/op | 1686.55 μs/op (3) | 1534.74 μs/op | 2041.22 μs/op | 5533.04 μs/op |
-
-
-__HiPE__:
-
-|                  | jiffy        | jsone             | poison        | jazz          | jsx           |
-|:-----------------|-------------:|------------------:|--------------:|--------------:|--------------:|
-| maps             |   7.69 μs/op |    6.12 μs/op (1) |   12.32 μs/op |   22.90 μs/op |   27.03 μs/op |
-| lists            | 207.75 μs/op |   69.93 μs/op (1) |   79.04 μs/op |  229.95 μs/op |  278.01 μs/op |
-| strings*         |  96.67 μs/op |  321.69 μs/op (5) |  142.43 μs/op |  310.10 μs/op |  179.96 μs/op |
-| string escaping* | 146.85 μs/op |  317.10 μs/op (2) | 1277.54 μs/op | 1311.85 μs/op |  767.67 μs/op |
-| large value**    | 409.73 μs/op |  664.34 μs/op (2) |  806.24 μs/op | 1630.21 μs/op | 1777.62 μs/op |
-| pretty print**   | 419.55 μs/op |  724.28 μs/op (2) |  844.76 μs/op | 1888.71 μs/op | 4872.34 μs/op |
-
-\* binary representation of [UTF-8-demo.txt](https://github.com/devinus/poison/blob/2.1.0/bench/data/UTF-8-demo.txt)  <br />
-\** [generated.json](https://github.com/devinus/poison/blob/2.1.0/bench/data/generated.json)
-
-### ParserBench Result
-
-__Non HiPE__:
-
-|                    | jiffy        | jsone             | poison        | jsx           |
-|:-------------------|-------------:|------------------:|--------------:|--------------:|
-| json value*        | 544.84 μs/op | 1364.38 μs/op (2) | 1401.35 μs/op | 1844.55 μs/op |
-| UTF-8 unescaping** |  63.01 μs/op |  399.38 μs/op (4) |  249.70 μs/op |  281.84 μs/op |
-
-
-__HiPE__:
-
-|                    | jiffy        | jsone             | poison        | jsx           |
-|:-------------------|-------------:|------------------:|--------------:|--------------:|
-| json value*        | 542.77 μs/op |  561.15 μs/op (2) |  751.36 μs/op | 1435.10 μs/op |
-| UTF-8 unescaping** |  62.42 μs/op |   92.63 μs/op (2) |  118.97 μs/op |  172.07 μs/op |
-
-\* [generated.json](https://github.com/devinus/poison/blob/2.1.0/bench/data/generated.json) <br />
-\** [UTF-8-demo.txt](https://github.com/devinus/poison/blob/2.1.0/bench/data/UTF-8-demo.txt)
 
 License
 -------

+ 0 - 1
benchmark/README.md

@@ -56,7 +56,6 @@ Summary
 | [UTF-8 unescaped]          |     5.56 K | **12.54 K** | 1.35 K | 5.09 K (3) | 3.30 K | 4.39 K | 1.46 K |
 
 
-
 Details
 -------