@@ -99,16 +99,30 @@ pub struct ComparisonResult {
9999
100100impl ComparisonReport {
101101 pub fn print ( & self ) {
102- println ! ( "\n ╔══════════════════════════════════════════════════════════════════════════════════╗" ) ;
103- println ! ( "║ VECTOR DB COMPARISON ║" ) ;
104- println ! ( "║ {} vectors ║" , format_num( self . num_vectors) ) ;
105- println ! ( "╠══════════════════════════════════════════════════════════════════════════════════╣" ) ;
106- println ! ( "║ System │ Memory │ Latency │ Recall │ QPS │ $/1M queries ║" ) ;
107- println ! ( "╠═══════════════╪═════════════╪═════════════╪═════════╪════════════╪══════════════╣" ) ;
102+ println ! (
103+ "\n ╔══════════════════════════════════════════════════════════════════════════════════╗"
104+ ) ;
105+ println ! (
106+ "║ VECTOR DB COMPARISON ║"
107+ ) ;
108+ println ! (
109+ "║ {} vectors ║" ,
110+ format_num( self . num_vectors)
111+ ) ;
112+ println ! (
113+ "╠══════════════════════════════════════════════════════════════════════════════════╣"
114+ ) ;
115+ println ! (
116+ "║ System │ Memory │ Latency │ Recall │ QPS │ $/1M queries ║"
117+ ) ;
118+ println ! (
119+ "╠═══════════════╪═════════════╪═════════════╪═════════╪════════════╪══════════════╣"
120+ ) ;
108121
109122 for ( db, result) in & self . results {
110123 let highlight = if * db == VectorDB :: Ladybug { "►" } else { " " } ;
111- println ! ( "║{}{:<13} │ {:>11} │ {:>11} │ {:>6.1}% │ {:>10} │ {:>12} ║" ,
124+ println ! (
125+ "║{}{:<13} │ {:>11} │ {:>11} │ {:>6.1}% │ {:>10} │ {:>12} ║" ,
112126 highlight,
113127 db. name( ) ,
114128 format_mb( result. memory_mb) ,
@@ -119,7 +133,9 @@ impl ComparisonReport {
119133 ) ;
120134 }
121135
122- println ! ( "╚═══════════════╧═════════════╧═════════════╧═════════╧════════════╧══════════════╝" ) ;
136+ println ! (
137+ "╚═══════════════╧═════════════╧═════════════╧═════════╧════════════╧══════════════╝"
138+ ) ;
123139
124140 // Calculate advantages
125141 if let ( Some ( ladybug) , Some ( qdrant) ) = (
@@ -128,12 +144,18 @@ impl ComparisonReport {
128144 ) {
129145 println ! ( "\n ┌─────────────────────────────────────────────────────────────┐" ) ;
130146 println ! ( "│ LADYBUG ADVANTAGES vs Qdrant: │" ) ;
131- println ! ( "│ Memory: {:.1}x LESS RAM │" ,
132- qdrant. 1 . memory_mb / ladybug. 1 . memory_mb) ;
133- println ! ( "│ Speed: {:.1}x FASTER │" ,
134- qdrant. 1 . latency_us as f64 / ladybug. 1 . latency_us as f64 ) ;
135- println ! ( "│ Cost: {:.1}x CHEAPER │" ,
136- qdrant. 1 . cost_per_1m_queries / ladybug. 1 . cost_per_1m_queries) ;
147+ println ! (
148+ "│ Memory: {:.1}x LESS RAM │" ,
149+ qdrant. 1 . memory_mb / ladybug. 1 . memory_mb
150+ ) ;
151+ println ! (
152+ "│ Speed: {:.1}x FASTER │" ,
153+ qdrant. 1 . latency_us as f64 / ladybug. 1 . latency_us as f64
154+ ) ;
155+ println ! (
156+ "│ Cost: {:.1}x CHEAPER │" ,
157+ qdrant. 1 . cost_per_1m_queries / ladybug. 1 . cost_per_1m_queries
158+ ) ;
137159 println ! ( "└─────────────────────────────────────────────────────────────┘" ) ;
138160 }
139161 }
@@ -150,33 +172,39 @@ pub fn compare_all(num_vectors: usize) -> ComparisonReport {
150172 VectorDB :: Chroma ,
151173 ] ;
152174
153- let results: Vec < _ > = dbs. into_iter ( ) . map ( |db| {
154- let bytes = db. bytes_per_vector ( ) * num_vectors;
155- let memory_mb = bytes as f64 / ( 1024.0 * 1024.0 ) ;
156- let latency_us = db. typical_latency_us ( num_vectors) ;
157- let recall = db. typical_recall ( ) ;
158- let qps = 1_000_000.0 / latency_us as f64 ;
159-
160- // Cost estimation:
161- // - Ladybug: self-hosted, ~$0.001/1M (CPU only)
162- // - Cloud services: ~$0.05-0.50/1M depending on provider
163- let cost_per_1m_queries = match db {
164- VectorDB :: Ladybug => 0.001 ,
165- VectorDB :: Qdrant => 0.02 ,
166- VectorDB :: Milvus => 0.03 ,
167- VectorDB :: Weaviate => 0.05 ,
168- VectorDB :: Pinecone => 0.10 ,
169- VectorDB :: Chroma => 0.01 ,
170- } ;
171-
172- ( db, ComparisonResult {
173- memory_mb,
174- latency_us,
175- recall,
176- qps,
177- cost_per_1m_queries,
175+ let results: Vec < _ > = dbs
176+ . into_iter ( )
177+ . map ( |db| {
178+ let bytes = db. bytes_per_vector ( ) * num_vectors;
179+ let memory_mb = bytes as f64 / ( 1024.0 * 1024.0 ) ;
180+ let latency_us = db. typical_latency_us ( num_vectors) ;
181+ let recall = db. typical_recall ( ) ;
182+ let qps = 1_000_000.0 / latency_us as f64 ;
183+
184+ // Cost estimation:
185+ // - Ladybug: self-hosted, ~$0.001/1M (CPU only)
186+ // - Cloud services: ~$0.05-0.50/1M depending on provider
187+ let cost_per_1m_queries = match db {
188+ VectorDB :: Ladybug => 0.001 ,
189+ VectorDB :: Qdrant => 0.02 ,
190+ VectorDB :: Milvus => 0.03 ,
191+ VectorDB :: Weaviate => 0.05 ,
192+ VectorDB :: Pinecone => 0.10 ,
193+ VectorDB :: Chroma => 0.01 ,
194+ } ;
195+
196+ (
197+ db,
198+ ComparisonResult {
199+ memory_mb,
200+ latency_us,
201+ recall,
202+ qps,
203+ cost_per_1m_queries,
204+ } ,
205+ )
178206 } )
179- } ) . collect ( ) ;
207+ . collect ( ) ;
180208
181209 ComparisonReport {
182210 num_vectors,
@@ -210,7 +238,11 @@ pub fn run_comparison_benchmark(config: BenchConfig) -> ComparisonReport {
210238 let mut report = compare_all ( config. num_vectors ) ;
211239
212240 // Update Ladybug with real measurements
213- if let Some ( ( _, result) ) = report. results . iter_mut ( ) . find ( |( db, _) | * db == VectorDB :: Ladybug ) {
241+ if let Some ( ( _, result) ) = report
242+ . results
243+ . iter_mut ( )
244+ . find ( |( db, _) | * db == VectorDB :: Ladybug )
245+ {
214246 result. latency_us = ladybug_latency;
215247 result. memory_mb = ladybug_memory as f64 / ( 1024.0 * 1024.0 ) ;
216248 result. qps = 1_000_000.0 / ladybug_latency as f64 ;
@@ -277,12 +309,16 @@ mod tests {
277309 report. print ( ) ;
278310
279311 // Ladybug should use less memory than Qdrant
280- let ladybug_mem = report. results . iter ( )
312+ let ladybug_mem = report
313+ . results
314+ . iter ( )
281315 . find ( |( db, _) | * db == VectorDB :: Ladybug )
282316 . map ( |( _, r) | r. memory_mb )
283317 . unwrap ( ) ;
284318
285- let qdrant_mem = report. results . iter ( )
319+ let qdrant_mem = report
320+ . results
321+ . iter ( )
286322 . find ( |( db, _) | * db == VectorDB :: Qdrant )
287323 . map ( |( _, r) | r. memory_mb )
288324 . unwrap ( ) ;
0 commit comments