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 M5 Pro
Number of Available Cores 18
Available Memory 48 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 8.55 K 117.02 µs ±24.09% 111.15 µs 242.18 µs

Run Time Comparison

Name IPS Slower
Json.stringify/1 8.55 K  

Memory Usage

Name Average Factor
Json.stringify/1 508.79 KB  

Input: nested (depth 5)

Run Time

Name IPS Average Deviation Median 99th %
Json.stringify/1 93.45 K 10.70 µs ±25.98% 10.08 µs 20.13 µs

Run Time Comparison

Name IPS Slower
Json.stringify/1 93.45 K  

Memory Usage

Name Average Factor
Json.stringify/1 62.61 KB  

Input: shallow (depth 1)

Run Time

Name IPS Average Deviation Median 99th %
Json.stringify/1 1.96 M 509.08 ns ±899.84% 458 ns 708 ns

Run Time Comparison

Name IPS Slower
Json.stringify/1 1.96 M  

Memory Usage

Name Average Factor
Json.stringify/1 2.97 KB