Skip to content

Commit 525a801

Browse files
PragTobmichalmuskala
authored andcommitted
Adopt benchee 1.0 and work around dependency problems (michalmuskala#74)
Best solution I know for the "benchee depends on Jason" problem is a small separate mix project. I do the same in deep_merge and it works out fine. Only downgrade right now is that you have to do cd `bench` and then `mix bench.encode` - I suspect we can make it work without didn't look it up because I assume Michał would know right away either way :) Happy benchmarking!
1 parent be2153c commit 525a801

File tree

8 files changed

+62
-44
lines changed

8 files changed

+62
-44
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ erl_crash.dump
2121

2222
# Ignore benchmark output
2323
/bench/output
24-
/bench/snapshots
24+
/bench/snapshots
25+
26+
# Ignore benchmark specific dependencies etc (separate project to work around problems with dependencies)
27+
/bench/_build
28+
/bench/deps

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ http://michal.muskala.eu/jason/decode.html and http://michal.muskala.eu/jason/en
116116

117117
### Running
118118

119-
Benchmarks against most popular Elixir & Erlang json libraries can be executed
120-
with `mix bench.encode` and `mix bench.decode`.
119+
Benchmarks against most popular Elixir & Erlang json libraries can be executed after
120+
going into the `bench/` folder and then executing `mix bench.encode` and `mix bench.decode`.
121121
A HTML report of the benchmarks (after their execution) can be found in
122122
`bench/output/encode.html` and `bench/output/decode.html` respectively.
123123

bench/decode.exs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ Benchee.run(decode_jobs,
4444
memory_time: 1,
4545
inputs: inputs,
4646
formatters: [
47-
&Benchee.Formatters.HTML.output/1,
48-
&Benchee.Formatters.Console.output/1,
49-
],
50-
formatter_options: [
51-
html: [
52-
file: Path.expand("output/decode.html", __DIR__)
53-
]
47+
{Benchee.Formatters.HTML, file: Path.expand("output/decode.html", __DIR__)},
48+
Benchee.Formatters.Console,
5449
]
5550
)

bench/encode.exs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ Benchee.run(encode_jobs,
4444
|> (&{name, &1}).()
4545
end,
4646
formatters: [
47-
&Benchee.Formatters.HTML.output/1,
48-
&Benchee.Formatters.Console.output/1,
49-
],
50-
formatter_options: [
51-
html: [
52-
file: Path.expand("output/encode.html", __DIR__)
53-
]
47+
{Benchee.Formatters.HTML, file: Path.expand("output/encode.html", __DIR__)},
48+
Benchee.Formatters.Console
5449
]
5550
)

bench/mix.exs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
defmodule JasonBench.MixProject do
2+
use Mix.Project
3+
4+
def project do
5+
[
6+
app: :jason_bench,
7+
version: "0.1.0",
8+
elixir: "~> 1.6",
9+
start_permanent: Mix.env() == :prod,
10+
deps: deps(),
11+
aliases: aliases()
12+
]
13+
end
14+
15+
defp aliases() do
16+
[
17+
"bench.encode": ["run encode.exs"],
18+
"bench.decode": ["run decode.exs"]
19+
]
20+
end
21+
22+
# Run "mix help deps" to learn about dependencies.
23+
defp deps do
24+
[
25+
{:jason, "~> 1.0", path: "../", override: true},
26+
{:benchee, "~> 1.0"},
27+
{:benchee_html, "~> 1.0"},
28+
{:poison, "~> 3.0"},
29+
{:exjsx, "~> 4.0"},
30+
{:tiny, "~> 1.0"},
31+
{:jsone, "~> 1.4"},
32+
{:jiffy, "~> 0.14"},
33+
{:json, "~> 1.0"},
34+
]
35+
end
36+
end

bench/mix.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
%{
2+
"benchee": {:hex, :benchee, "1.0.0", "2524b6c0e541309d969accf75f77e1d1653e46142afc68e9ea4ff35559a794bc", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm"},
3+
"benchee_html": {:hex, :benchee_html, "1.0.0", "5b4d24effebd060f466fb460ec06576e7b34a00fc26b234fe4f12c4f05c95947", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:benchee_json, "~> 1.0", [hex: :benchee_json, repo: "hexpm", optional: false]}], "hexpm"},
4+
"benchee_json": {:hex, :benchee_json, "1.0.0", "cc661f4454d5995c08fe10dd1f2f72f229c8f0fb1c96f6b327a8c8fc96a91fe5", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
5+
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm"},
6+
"exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"},
7+
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
8+
"jiffy": {:hex, :jiffy, "0.15.2", "de266c390111fd4ea28b9302f0bc3d7472468f3b8e0aceabfbefa26d08cd73b7", [:rebar3], [], "hexpm"},
9+
"json": {:hex, :json, "1.2.1", "21e8d6983091660f394f44a7c11f8cf1f467afb2aada1fcf59c2f1b590a42f68", [:mix], [], "hexpm"},
10+
"jsone": {:hex, :jsone, "1.4.7", "a970c23d9700ae7842b526c57677e6e3f10894b429524696ead547e9302391c0", [:rebar3], [], "hexpm"},
11+
"jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm"},
12+
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
13+
"tiny": {:hex, :tiny, "1.0.1", "535ea7e600cb1c6ba17b53029266d9d7ec54ce29bfb05d906c433907acfa01ca", [:mix], [], "hexpm"},
14+
}

mix.exs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ defmodule Jason.Mixfile do
1111
start_permanent: Mix.env() == :prod,
1212
consolidate_protocols: Mix.env() != :test,
1313
deps: deps(),
14-
aliases: aliases(),
15-
preferred_cli_env: ["bench.encode": :bench, "bench.decode": :bench, docs: :docs],
14+
preferred_cli_env: [docs: :docs],
1615
dialyzer: dialyzer(),
1716
description: description(),
1817
package: package(),
@@ -29,14 +28,6 @@ defmodule Jason.Mixfile do
2928
defp deps() do
3029
[
3130
{:decimal, "~> 1.0", optional: true},
32-
{:benchee, "~> 0.8", only: :bench},
33-
{:benchee_html, "~> 0.1", only: :bench, github: "michalmuskala/benchee_html"},
34-
{:poison, "~> 3.0", only: :bench},
35-
{:exjsx, "~> 4.0", only: :bench},
36-
{:tiny, "~> 1.0", only: :bench},
37-
{:jsone, "~> 1.4", only: :bench},
38-
{:jiffy, "~> 0.14", only: :bench},
39-
{:json, "~> 1.0", only: :bench},
4031
{:dialyxir, "~> 0.5", only: [:dev, :test], runtime: false},
4132
{:ex_doc, "~> 0.18", only: :docs},
4233
] ++ maybe_stream_data()
@@ -50,13 +41,6 @@ defmodule Jason.Mixfile do
5041
end
5142
end
5243

53-
defp aliases() do
54-
[
55-
"bench.encode": ["run bench/encode.exs"],
56-
"bench.decode": ["run bench/decode.exs"]
57-
]
58-
end
59-
6044
defp dialyzer() do
6145
[
6246
ignore_warnings: "dialyzer.ignore"

mix.lock

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
%{
2-
"benchee": {:hex, :benchee, "0.13.1", "bd93ca05be78bcb6159c7176230efeda2f724f7ffd485515175ca411dff4893e", [:mix], [{:deep_merge, "~> 0.1", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm"},
3-
"benchee_html": {:git, "https://github.com/michalmuskala/benchee_html.git", "e3f60b891b115dd599c9387637e4c36cc0269d7d", []},
42
"decimal": {:hex, :decimal, "1.5.0", "b0433a36d0e2430e3d50291b1c65f53c37d56f83665b43d79963684865beab68", [:mix], [], "hexpm"},
5-
"deep_merge": {:hex, :deep_merge, "0.1.1", "c27866a7524a337b6a039eeb8dd4f17d458fd40fbbcb8c54661b71a22fffe846", [:mix], [], "hexpm"},
63
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
74
"earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], [], "hexpm"},
85
"ex_doc": {:hex, :ex_doc, "0.19.1", "519bb9c19526ca51d326c060cb1778d4a9056b190086a8c6c115828eaccea6cf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
9-
"exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"},
10-
"jiffy": {:hex, :jiffy, "0.15.2", "de266c390111fd4ea28b9302f0bc3d7472468f3b8e0aceabfbefa26d08cd73b7", [:rebar3], [], "hexpm"},
11-
"json": {:hex, :json, "1.0.3", "547d58dbbd864c0a560c0ca3789ee8848974e8c517cdb7827c3303e3b42e754d", [:mix], [], "hexpm"},
12-
"jsone": {:hex, :jsone, "1.4.6", "644d6d57befb22c8e19b324dee19d73b1c004565009861a8f64c68b7b9e64dbf", [:rebar3], [], "hexpm"},
13-
"jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm"},
146
"makeup": {:hex, :makeup, "0.5.5", "9e08dfc45280c5684d771ad58159f718a7b5788596099bdfb0284597d368a882", [:mix], [{:nimble_parsec, "~> 0.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
157
"makeup_elixir": {:hex, :makeup_elixir, "0.10.0", "0f09c2ddf352887a956d84f8f7e702111122ca32fbbc84c2f0569b8b65cbf7fa", [:mix], [{:makeup, "~> 0.5.5", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
168
"nimble_parsec": {:hex, :nimble_parsec, "0.4.0", "ee261bb53214943679422be70f1658fff573c5d0b0a1ecd0f18738944f818efe", [:mix], [], "hexpm"},
17-
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
189
"stream_data": {:hex, :stream_data, "0.4.2", "fa86b78c88ec4eaa482c0891350fcc23f19a79059a687760ddcf8680aac2799b", [:mix], [], "hexpm"},
19-
"tiny": {:hex, :tiny, "1.0.1", "535ea7e600cb1c6ba17b53029266d9d7ec54ce29bfb05d906c433907acfa01ca", [:mix], [], "hexpm"},
2010
}

0 commit comments

Comments
 (0)