1+ #!/usr/bin/env python3
2+ import matplotlib .pyplot as plt
3+ import numpy as np
4+
5+ # Set up the style
6+ plt .style .use ('default' )
7+ plt .rcParams ['figure.facecolor' ] = 'white'
8+ plt .rcParams ['axes.facecolor' ] = 'white'
9+ plt .rcParams ['font.size' ] = 12
10+ plt .rcParams ['font.weight' ] = 'bold'
11+
12+ # Data for the charts
13+ libraries = ['nlohmann::json' , 'RapidJSON' , 'Serde (Rust)' , 'yyjson' ]
14+ speeds = [242 , 497 , 1343 , 2074 ]
15+ colors = ['#2E86AB' , '#A23B72' , '#F18F01' , '#C73E1D' ]
16+
17+ # Chart 1: Current Landscape (without simdjson)
18+ fig , ax = plt .subplots (figsize = (12 , 6 ))
19+ bars = ax .barh (libraries , speeds , color = colors , height = 0.6 )
20+ ax .set_xlabel ('Speed (MB/s)' , fontsize = 14 , fontweight = 'bold' )
21+ ax .set_title ('Current JSON Serialization Landscape' , fontsize = 16 , fontweight = 'bold' )
22+ ax .set_xlim (0 , 2500 )
23+ ax .grid (axis = 'x' , alpha = 0.3 , linestyle = '--' )
24+
25+ # Add value labels on bars
26+ for bar , speed in zip (bars , speeds ):
27+ ax .text (bar .get_width () + 50 , bar .get_y () + bar .get_height ()/ 2 ,
28+ f'{ speed } MB/s' , va = 'center' , fontweight = 'bold' )
29+
30+ plt .tight_layout ()
31+ plt .savefig ('/Users/random_person/Desktop/simdjson_talks/cppcon2025/images/perf_landscape.png' ,
32+ dpi = 150 , bbox_inches = 'tight' , facecolor = 'white' )
33+ plt .close ()
34+
35+ # Chart 2: With simdjson reveal
36+ libraries_with_simdjson = ['nlohmann::json' , 'RapidJSON' , 'Serde (Rust)' , 'yyjson' , 'simdjson' ]
37+ speeds_with_simdjson = [242 , 497 , 1343 , 2074 , 3435 ]
38+ colors_with_simdjson = ['#2E86AB' , '#A23B72' , '#F18F01' , '#C73E1D' , '#00A878' ]
39+
40+ fig , ax = plt .subplots (figsize = (14 , 6 )) # Wider figure
41+ bars = ax .barh (libraries_with_simdjson , speeds_with_simdjson , color = colors_with_simdjson , height = 0.6 )
42+ ax .set_xlabel ('Speed (MB/s)' , fontsize = 14 , fontweight = 'bold' )
43+ ax .set_title ('JSON Serialization Performance Comparison' , fontsize = 16 , fontweight = 'bold' )
44+ ax .set_xlim (0 , 4000 ) # Extended x-axis limit
45+ ax .grid (axis = 'x' , alpha = 0.3 , linestyle = '--' )
46+
47+ # Add value labels on bars
48+ for bar , speed , lib in zip (bars , speeds_with_simdjson , libraries_with_simdjson ):
49+ label = f'{ speed } MB/s ⭐' if lib == 'simdjson' else f'{ speed } MB/s'
50+ ax .text (bar .get_width () + 50 , bar .get_y () + bar .get_height ()/ 2 ,
51+ label , va = 'center' , fontweight = 'bold' )
52+
53+ # Highlight simdjson bar
54+ bars [- 1 ].set_edgecolor ('gold' )
55+ bars [- 1 ].set_linewidth (3 )
56+
57+ plt .tight_layout ()
58+ plt .savefig ('/Users/random_person/Desktop/simdjson_talks/cppcon2025/images/perf_with_simdjson.png' ,
59+ dpi = 150 , bbox_inches = 'tight' , facecolor = 'white' )
60+ plt .close ()
61+
62+ # Chart 3: Final comparison (sorted by performance)
63+ libraries_sorted = ['simdjson' , 'yyjson' , 'Serde (Rust)' , 'RapidJSON' , 'nlohmann::json' ]
64+ speeds_sorted = [3435 , 2074 , 1343 , 497 , 242 ]
65+ colors_sorted = ['#00A878' , '#C73E1D' , '#F18F01' , '#A23B72' , '#2E86AB' ]
66+
67+ fig , ax = plt .subplots (figsize = (14 , 6 )) # Wider figure
68+ bars = ax .barh (libraries_sorted , speeds_sorted , color = colors_sorted , height = 0.6 )
69+ ax .set_xlabel ('Speed (MB/s)' , fontsize = 14 , fontweight = 'bold' )
70+ ax .set_title ('Twitter Dataset (631KB) - Serialization Performance' , fontsize = 16 , fontweight = 'bold' )
71+ ax .set_xlim (0 , 4000 ) # Extended x-axis limit
72+ ax .grid (axis = 'x' , alpha = 0.3 , linestyle = '--' )
73+
74+ # Add value labels on bars
75+ for bar , speed , lib in zip (bars , speeds_sorted , libraries_sorted ):
76+ label = f'{ speed } MB/s ⭐' if lib == 'simdjson' else f'{ speed } MB/s'
77+ ax .text (bar .get_width () + 50 , bar .get_y () + bar .get_height ()/ 2 ,
78+ label , va = 'center' , fontweight = 'bold' )
79+
80+ # Highlight simdjson bar
81+ bars [0 ].set_edgecolor ('gold' )
82+ bars [0 ].set_linewidth (3 )
83+
84+ plt .tight_layout ()
85+ plt .savefig ('/Users/random_person/Desktop/simdjson_talks/cppcon2025/images/perf_comparison.png' ,
86+ dpi = 150 , bbox_inches = 'tight' , facecolor = 'white' )
87+ plt .close ()
88+
89+ print ("Charts generated successfully!" )
90+ print ("- perf_landscape.png: Current landscape without simdjson" )
91+ print ("- perf_with_simdjson.png: Performance comparison with simdjson" )
92+ print ("- perf_comparison.png: Final sorted comparison" )
0 commit comments