33
44# Chart 1: Current landscape (without simdjson) 
55libraries_landscape  =  ["nlohmann::json" , "RapidJSON" , "Serde (Rust)" , "yyjson" ]
6- speeds_landscape  =  [242 ,  497 ,  1343 ,  2074 ]
6+ speeds_landscape  =  [174 ,  529 ,  1710 ,  1909 ]
77colors_landscape  =  ['#8B8680' , '#6495ED' , '#FF6F61' , '#2ECC71' ]
88
99plt .figure (figsize = (10 , 6 ))
3535
3636# Chart 2: With simdjson reveal 
3737libraries_with  =  ["nlohmann::json" , "RapidJSON" , "Serde (Rust)" , "yyjson" , "simdjson" ]
38- speeds_with  =  [242 ,  497 ,  1343 ,  2074 ,  3435 ]
38+ speeds_with  =  [174 ,  529 ,  1710 ,  1909 ,  3598 ]
3939colors_with  =  ['#8B8680' , '#6495ED' , '#FF6F61' , '#2ECC71' , '#FFD700' ]
4040
4141plt .figure (figsize = (10 , 6 ))
6969plt .savefig ('perf_with_simdjson.png' , dpi = 300 , bbox_inches = 'tight' )
7070plt .close ()
7171
72- 
7372# Chart 2b: Parsing only (same style) 
7473plt .figure (figsize = (10 , 6 ))
75- bars  =  plt .bar (libraries_with , [172 , 658 , 1720 , 2230 ,  4090 ], color = colors_with , edgecolor = 'black' )
74+ bars  =  plt .bar (libraries_with , [172 , 658 , 1720 , 2637 ,  4170 ], color = colors_with , edgecolor = 'black' )
7675ax  =  plt .gca ()
7776ax .spines ['top' ].set_visible (False )
7877ax .spines ['right' ].set_visible (False )
9998
10099
101100
102- # Chart 3: Final comparison (sorted) 
103- libraries_sorted  =  ["simdjson" , "yyjson" , "Serde (Rust)" , "RapidJSON" , "nlohmann::json" ]
104- speeds_sorted  =  [3435 , 2074 , 1343 , 497 , 242 ]
105- colors_sorted  =  ['#FFD700' , '#2ECC71' , '#FF6F61' , '#6495ED' , '#8B8680' ]
106- 
107- plt .figure (figsize = (10 , 6 ))
108- bars  =  plt .bar (libraries_sorted , speeds_sorted , color = colors_sorted , edgecolor = 'black' )
109101
110- ax  =  plt .gca ()
111- ax .spines ['top' ].set_visible (False )
112- ax .spines ['right' ].set_visible (False )
113102
114- lang_labels  =  ["C++" , "C" , "Rust" , "C++" , "C++" ]
115- for  i , bar  in  enumerate (bars ):
116-     yval  =  bar .get_height ()
117-     label  =  f'{ yval }   MB/s '  if  libraries_sorted [i ] ==  'simdjson'  else  f'{ yval }   MB/s' 
118-     plt .text (bar .get_x () +  bar .get_width ()/ 2 , yval  +  50 , label ,
119-              ha = 'center' , va = 'bottom' , fontsize = 12 )
120-     plt .text (bar .get_x () +  bar .get_width ()/ 2 , yval  +  150 , lang_labels [i ],
121-              ha = 'center' , va = 'bottom' , fontsize = 12 , color = 'black' , fontweight = 'bold' , style = 'italic' )
122- 
123- # Highlight simdjson 
124- bars [0 ].set_linewidth (3 )
125- bars [0 ].set_edgecolor ('#FF0000' )
126- 
127- plt .ylabel ('Throughput (MB/s)' , fontsize = 14 )
128- plt .ylim (0 , 4000 )
129- plt .title ('Twitter Dataset (631KB) - Serialization Performance' , fontsize = 16 )
130- plt .text (0.01 , 0.99 , 'Apple Silicon (M3 MAX)' , transform = ax .transAxes ,
131-          fontsize = 14 , ha = 'left' , va = 'top' , style = 'italic' , color = 'black' )
132- plt .text (0.01 , 0.89 , 'twitter.json' , transform = ax .transAxes ,
133-          fontsize = 14 , ha = 'left' , va = 'top' , style = 'italic' , color = 'black' )
134- plt .tight_layout ()
135- plt .savefig ('perf_comparison.png' , dpi = 300 , bbox_inches = 'tight' )
136- plt .close ()
137103
138104print ("Performance charts generated successfully!" )
0 commit comments