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 M2
Number of Available Cores 8
Available Memory 8 GB
Elixir Version 1.20.4
Erlang Version 29.0.4

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 5.72 K 174.95 µs ±17.87% 167.79 µs 314.41 µs

Run Time Comparison

Name IPS Slower
Json.stringify/1 5.72 K  

Memory Usage

Name Average Factor
Json.stringify/1 438.84 KB  

Input: nested (depth 5)

Run Time

Name IPS Average Deviation Median 99th %
Json.stringify/1 58.29 K 17.16 µs ±15.69% 16.75 µs 20.96 µs

Run Time Comparison

Name IPS Slower
Json.stringify/1 58.29 K  

Memory Usage

Name Average Factor
Json.stringify/1 54.02 KB  

Input: shallow (depth 1)

Run Time

Name IPS Average Deviation Median 99th %
Json.stringify/1 1.19 M 840.25 ns ±693.15% 792 ns 1083 ns

Run Time Comparison

Name IPS Slower
Json.stringify/1 1.19 M  

Memory Usage

Name Average Factor
Json.stringify/1 2.55 KB