Skip to content

Instantly share code, notes, and snippets.

@michaelst
Last active August 18, 2025 13:28
Show Gist options
  • Save michaelst/12f66333dd053e93a243ba9bcc1d59eb to your computer and use it in GitHub Desktop.
Save michaelst/12f66333dd053e93a243ba9bcc1d59eb to your computer and use it in GitHub Desktop.
ElixirConf 2025
Mix.install([
:benchee,
{:brotli, github: "tellerhq/erl-brotli", branch: "master", override: true},
])
payload = File.read!("small.json")
IO.inspect(byte_size(payload), label: "payload size")
:brotli.encode(payload, %{quality: 5}) |> elem(1) |> byte_size() |> IO.inspect(label: "brotli")
IO.inspect(byte_size(:zlib.gzip(payload)), label: "gzip")
Benchee.run(
%{
"brotli" => fn -> :brotli.encode(payload, %{quality: 5}) end,
"gzip" => fn -> :zlib.gzip(payload) end,
},
time: 10,
memory_time: 2
)
payload size: 797920
brotli: 20160
gzip: 139151
Operating System: macOS
CPU Information: Apple M1 Max
Number of Available Cores: 10
Available memory: 64 GB
Elixir 1.18.4
Erlang 28.0.2
JIT enabled: true
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 10 s
memory time: 2 s
reduction time: 0 ns
parallel: 1
inputs: none specified
Estimated total run time: 28 s
Benchmarking brotli ...
Benchmarking gzip ...
Calculating statistics...
Formatting results...
Name ips average deviation median 99th %
brotli 496.03 2.02 ms ±7.21% 1.99 ms 2.35 ms
gzip 50.93 19.63 ms ±2.17% 19.55 ms 20.61 ms
Comparison:
brotli 496.03
gzip 50.93 - 9.74x slower +17.62 ms
Memory usage statistics:
Name Memory usage
brotli 0.50 KB
gzip 4.68 KB - 9.36x memory usage +4.18 KB
payload size: 15408
brotli: 3092
gzip: 3280
Operating System: macOS
CPU Information: Apple M1 Max
Number of Available Cores: 10
Available memory: 64 GB
Elixir 1.18.4
Erlang 28.0.2
JIT enabled: true
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 10 s
memory time: 2 s
reduction time: 0 ns
parallel: 1
inputs: none specified
Estimated total run time: 28 s
Benchmarking brotli ...
Benchmarking gzip ...
Calculating statistics...
Formatting results...
Name ips average deviation median 99th %
gzip 7.07 K 141.51 μs ±17.59% 137.17 μs 241.11 μs
brotli 4.48 K 223.31 μs ±50.49% 215.63 μs 800.43 μs
Comparison:
gzip 7.07 K
brotli 4.48 K - 1.58x slower +81.80 μs
Memory usage statistics:
Name Memory usage
gzip 376 B
brotli 512 B - 1.36x memory usage +136 B
sequenceDiagram
    actor User
    participant CodeMirror webcomponent
    participant DataTable webcomponent
    participant LiveView
    participant Repo.stream task
    User->>CodeMirror webcomponent: type query into editor
    User->>LiveView: click run query button
    LiveView->>CodeMirror webcomponent: push_event to get query
    CodeMirror webcomponent->>LiveView: send query
    LiveView->>Repo.stream task: start task and run Repo.stream
    Repo.stream task->>LiveView: send data chunk
    LiveView->>DataTable webcomponent: push_event to send data chunk to browser
Loading
payload size: 4646
brotli: 1305
gzip: 1425
Operating System: macOS
CPU Information: Apple M1 Max
Number of Available Cores: 10
Available memory: 64 GB
Elixir 1.18.4
Erlang 28.0.2
JIT enabled: true
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 10 s
memory time: 2 s
reduction time: 0 ns
parallel: 1
inputs: none specified
Estimated total run time: 28 s
Benchmarking brotli ...
Benchmarking gzip ...
Calculating statistics...
Formatting results...
Name ips average deviation median 99th %
gzip 33.96 K 29.45 μs ±23.27% 28.58 μs 44.46 μs
brotli 6.71 K 149.11 μs ±122.14% 136.50 μs 439.78 μs
Comparison:
gzip 33.96 K
brotli 6.71 K - 5.06x slower +119.66 μs
Memory usage statistics:
Name Memory usage
gzip 200 B
brotli 512 B - 2.56x memory usage +312 B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment