Benchmark

stringify/1 runs over every piece of metadata in every module and node, so it is called far more often than anything else here and its cost is dominated by tree depth.

System

Benchmark suite executing on the following system:

Operating System macOS
CPU Information Apple M4 Max
Number of Available Cores 16
Available Memory 128 GB
Elixir Version 1.18.4
Erlang Version 27.3.4.15

Configuration

Benchmark suite executing with the following configuration:

:time 5 s
:parallel 1
:warmup 2 s

Statistics

Input: deep (depth 8)

Run Time

Name IPS Average Deviation Median 99th %
Json.stringify/1 13.18 K 75.86 µs ±17.20% 70 µs 133.38 µs

Run Time Comparison

Name IPS Slower
Json.stringify/1 13.18 K  

Memory Usage

Name Average Factor
Json.stringify/1 297.18 KB  

Input: nested (depth 5)

Run Time

Name IPS Average Deviation Median 99th %
Json.stringify/1 134.05 K 7.46 µs ±45.94% 7.04 µs 15.96 µs

Run Time Comparison

Name IPS Slower
Json.stringify/1 134.05 K  

Memory Usage

Name Average Factor
Json.stringify/1 36.50 KB  

Input: shallow (depth 1)

Run Time

Name IPS Average Deviation Median 99th %
Json.stringify/1 2.74 M 364.87 ns ±1357.20% 333 ns 500 ns

Run Time Comparison

Name IPS Slower
Json.stringify/1 2.74 M  

Memory Usage

Name Average Factor
Json.stringify/1 1.73 KB