@@ -131,17 +131,40 @@ def annotate(v):
131131# ─────────────────────────────────────────────────────────────────────────────
132132# Plots
133133# ─────────────────────────────────────────────────────────────────────────────
134+ def ensure_min_visible (arr , min_val ):
135+ """Ensure non-zero values are at least min_val for visibility on graph."""
136+ return [max (v , min_val ) if v > 0 else 0 for v in arr ]
137+
134138def bench1 ():
135139 """Horizontal bars – raw values (pixel scale)."""
136140 y , w = np .arange (len (ordered_ops )), 0.1
137141 fig , ax = plt .subplots (figsize = (12 , 8 ))
138142
139- ax .barh (y - 2 * w , du_volatile_arr , w , label = 'Doublets United Volatile' , color = 'salmon' )
140- ax .barh (y - w , du_nonvolatile_arr ,w , label = 'Doublets United NonVolatile' ,color = 'red' )
141- ax .barh (y , ds_volatile_arr , w , label = 'Doublets Split Volatile' , color = 'lightgreen' )
142- ax .barh (y + w , ds_nonvolatile_arr , w , label = 'Doublets Split NonVolatile' , color = 'green' )
143- ax .barh (y + 2 * w , neo4j_non_arr , w , label = 'Neo4j NonTransaction' , color = 'lightblue' )
144- ax .barh (y + 3 * w , neo4j_trans_arr , w , label = 'Neo4j Transaction' , color = 'blue' )
143+ # Calculate maximum value across all data series to determine scale
144+ all_values = (du_volatile_arr + du_nonvolatile_arr + ds_volatile_arr +
145+ ds_nonvolatile_arr + neo4j_non_arr + neo4j_trans_arr )
146+ max_val = max (all_values ) if all_values else 1
147+
148+ # Minimum visible bar width: ~0.5% of max value ensures at least 2 pixels
149+ # on typical 12-inch wide figure at 100 DPI (~900px plot area)
150+ min_visible = max_val * 0.005
151+ if DEBUG :
152+ logging .info ("bench1: max_val=%d, min_visible=%d" , max_val , min_visible )
153+
154+ # Apply minimum visibility to all data series
155+ du_volatile_vis = ensure_min_visible (du_volatile_arr , min_visible )
156+ du_nonvolatile_vis = ensure_min_visible (du_nonvolatile_arr , min_visible )
157+ ds_volatile_vis = ensure_min_visible (ds_volatile_arr , min_visible )
158+ ds_nonvolatile_vis = ensure_min_visible (ds_nonvolatile_arr , min_visible )
159+ neo4j_non_vis = ensure_min_visible (neo4j_non_arr , min_visible )
160+ neo4j_trans_vis = ensure_min_visible (neo4j_trans_arr , min_visible )
161+
162+ ax .barh (y - 2 * w , du_volatile_vis , w , label = 'Doublets United Volatile' , color = 'salmon' )
163+ ax .barh (y - w , du_nonvolatile_vis ,w , label = 'Doublets United NonVolatile' ,color = 'red' )
164+ ax .barh (y , ds_volatile_vis , w , label = 'Doublets Split Volatile' , color = 'lightgreen' )
165+ ax .barh (y + w , ds_nonvolatile_vis , w , label = 'Doublets Split NonVolatile' , color = 'green' )
166+ ax .barh (y + 2 * w , neo4j_non_vis , w , label = 'Neo4j NonTransaction' , color = 'lightblue' )
167+ ax .barh (y + 3 * w , neo4j_trans_vis , w , label = 'Neo4j Transaction' , color = 'blue' )
145168
146169 ax .set_xlabel ('Time (ns)' )
147170 ax .set_title ('Benchmark Comparison: Neo4j vs Doublets (Rust)' )
0 commit comments