Skip to content

Commit

Permalink
update bench deps
Browse files Browse the repository at this point in the history
  • Loading branch information
tony612 committed Jun 12, 2018
1 parent 7055288 commit 291639c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
5 changes: 3 additions & 2 deletions bench/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ defmodule ProtoBench.MixProject do

defp deps do
[
{:protobuf, "~> 0.5.3"},
# {:protobuf, "~> 0.5.3"},
{:protobuf, path: ".."},
{:benchee, "~> 0.12", only: :dev},
{:benchee_html, "~> 0.5", only: :dev},
{:benchee_html, "~> 0.5", only: :dev}
]
end
end
33 changes: 19 additions & 14 deletions bench/script/bench.exs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# TODO: group of proto2 is not supported
sets = Path.wildcard("**/dataset.google_message1*.pb")
|> Enum.map(&ProtoBench.load(&1))
|> Enum.reduce(%{}, fn(%{payload: [payload]} = s, acc) ->
mod = ProtoBench.mod_name(s.message_name)
msg = mod.decode(payload)
IO.inspect(msg)
acc
|> Map.put(s.name <> " Decode", fn() -> mod.decode(payload) end)
|> Map.put(s.name <> " Encode", fn() -> mod.encode(msg) end)
end)
sets =
Path.wildcard("**/dataset.google_message1*.pb")
|> Enum.map(&ProtoBench.load(&1))
|> Enum.reduce(%{}, fn %{payload: [payload]} = s, acc ->
mod = ProtoBench.mod_name(s.message_name)
msg = mod.decode(payload)
# IO.inspect(msg)
acc
|> Map.put(s.name <> " Decode", fn -> mod.decode(payload) end)
|> Map.put(s.name <> " Encode", fn -> mod.encode(msg) end)
end)

Benchee.run(sets, time: 10, formatters: [
Benchee.Formatters.HTML,
Benchee.Formatters.Console
])
Benchee.run(
sets,
time: 10,
formatters: [
Benchee.Formatters.HTML,
Benchee.Formatters.Console
]
)

0 comments on commit 291639c

Please sign in to comment.