Skip to content

Commit 0d44ac8

Browse files
Shubham Guptagoodhamgupta
Shubham Gupta
authored andcommitted
Add benchmark for snowplow requests
1 parent c045ef5 commit 0d44ac8

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ snowplow_elixir_tracker-*.tar
2424

2525
# Ignore elixir tables created using PersistentEts
2626
*.tab
27+
# Ignore benchee output files
28+
benchmarks/*

Diff for: config/config.exs

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ use Mix.Config
3232
config :snowplow_tracker,
3333
default_options: [
3434
timeout: 5000,
35-
recv_timeout: 2000
36-
],
37-
table: :snowplow_events
35+
recv_timeout: 2000,
36+
hackney: [pool: :snowplow_hackney_pool]
37+
]

Diff for: mix.exs

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ defmodule SnowplowTracker.MixProject do
3838
{:uuid, "~> 1.1"},
3939
{:persistent_ets, "~> 0.2.1"},
4040
{:ex_doc, "~> 0.11", only: :dev},
41+
{:benchee, "~> 1.0", only: :dev},
42+
{:benchee_html, "~> 1.0", only: :dev},
4143
{:mock, "~> 0.3.0", only: :test},
4244
{:excoveralls, "~> 0.8", only: :test}
4345
]

Diff for: mix.lock

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
%{
2+
"benchee": {:hex, :benchee, "1.0.1", "66b211f9bfd84bd97e6d1beaddf8fc2312aaabe192f776e8931cb0c16f53a521", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm"}, "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"},
3+
"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"},
24
"certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
5+
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm"},
36
"earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm"},
47
"ex_doc": {:hex, :ex_doc, "0.20.2", "1bd0dfb0304bade58beb77f20f21ee3558cc3c753743ae0ddbb0fd7ba2912331", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
58
"excoveralls": {:hex, :excoveralls, "0.11.1", "dd677fbdd49114fdbdbf445540ec735808250d56b011077798316505064edb2c", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},

Diff for: test/snowplow_tracker_benchmark.exs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
alias SnowplowTracker
2+
alias SnowplowTracker.Events.Structured
3+
alias SnowplowTracker.{Tracker, Emitter}
4+
5+
:hackney_pool.child_spec(:snowplow_hackney_pool, timeout: 60_000, max_connections: 500)
6+
emitter = %Emitter{collector_uri: "locahost", protocol: "http", request_type: "GET" }
7+
tracker = %Tracker{emitter: emitter}
8+
payload = Structured.new(%{category: "test", action: "test", value: 0.0})
9+
10+
11+
tracker_func = fn _ -> SnowplowTracker.track_struct_event(payload, tracker) end
12+
Benchee.run(
13+
%{
14+
"structured event" => fn -> (1..100000) |> Enum.each(tracker_func) end
15+
},
16+
formatters: [
17+
Benchee.Formatters.HTML,
18+
Benchee.Formatters.Console
19+
],
20+
time: 15,
21+
warmup: 5,
22+
parallel: 12
23+
)
24+

0 commit comments

Comments
 (0)