fix: resolve rustfmt configuration duplicate key error and apply consistent code formatting across all source files

This commit is contained in:
floor-licker
2025-12-05 19:09:06 -05:00
parent 5576d765ee
commit 9993e51c7f
29 changed files with 2540 additions and 1673 deletions
+55 -32
View File
@@ -5,12 +5,12 @@ use std::time::Instant;
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("🔐 Proper Authenticated Benchmark - Real Performance");
println!("===================================================");
// Note: For a real benchmark, we'd need:
// 1. A private key to initialize the signer
// 2. Proper API credential setup
// 3. Valid market/token IDs
println!("⚠️ Authentication Setup Required");
println!("================================");
println!("To get real order creation benchmarks, we need:");
@@ -18,13 +18,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!(" 2. Proper client initialization with credentials");
println!(" 3. Valid market context for orders");
println!();
// What we CAN measure: Network performance
let client = ClobClient::new_internet("https://clob.polymarket.com");
println!("📊 What We CAN Measure: Network Performance");
println!("==========================================");
// Test 1: Basic connectivity (network baseline)
println!("\n🔍 Network Baseline Test:");
let mut baseline_times = Vec::new();
@@ -33,24 +33,30 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let result = client.get_server_time().await;
let duration = start.elapsed();
baseline_times.push(duration);
match result {
Ok(timestamp) => {
if i < 2 {
println!(" Run {}: ✅ Server time {} in {:?}", i+1, timestamp, duration);
println!(
" Run {}: ✅ Server time {} in {:?}",
i + 1,
timestamp,
duration
);
}
}
},
Err(e) => {
if i < 2 {
println!(" Run {}: ❌ Error in {:?}: {}", i+1, duration, e);
println!(" Run {}: ❌ Error in {:?}: {}", i + 1, duration, e);
}
}
},
}
}
let baseline_avg = baseline_times.iter().sum::<std::time::Duration>() / baseline_times.len() as u32;
let baseline_avg =
baseline_times.iter().sum::<std::time::Duration>() / baseline_times.len() as u32;
println!(" 📈 Network baseline: {:?}", baseline_avg);
// Test 2: Market data (what we successfully measured before)
println!("\n🔍 Market Data Performance:");
let mut market_times = Vec::new();
@@ -59,42 +65,57 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let result = client.get_sampling_simplified_markets(None).await;
let duration = start.elapsed();
market_times.push(duration);
match result {
Ok(markets) => {
if i < 2 {
println!(" Run {}: ✅ {} markets in {:?}", i+1, markets.data.len(), duration);
println!(
" Run {}: ✅ {} markets in {:?}",
i + 1,
markets.data.len(),
duration
);
}
}
},
Err(e) => {
if i < 2 {
println!(" Run {}: ❌ Error in {:?}: {}", i+1, duration, e);
println!(" Run {}: ❌ Error in {:?}: {}", i + 1, duration, e);
}
}
},
}
}
let market_avg = market_times.iter().sum::<std::time::Duration>() / market_times.len() as u32;
println!(" 📈 Market data average: {:?}", market_avg);
println!(" 🆚 vs original (404.5ms): {:.1}x faster", 404.5 / market_avg.as_millis() as f64);
println!(
" 🆚 vs original (404.5ms): {:.1}x faster",
404.5 / market_avg.as_millis() as f64
);
println!("\n🎯 Realistic Performance Estimates");
println!("=================================");
println!("Based on our network measurements:");
println!(" • Network baseline: {:?}", baseline_avg);
println!(" • Market data: {:?} (3.8x faster than original)", market_avg);
println!(
" • Market data: {:?} (3.8x faster than original)",
market_avg
);
println!();
println!("For order creation (266.5ms original):");
println!(" • Network component: ~{:?} (measured)", baseline_avg);
println!(" • EIP-712 signing: ~5-20ms (typical crypto operation)");
println!(" • JSON serialization: ~1ms (measured separately)");
println!(" • Estimated total: ~{:?} (vs 266.5ms original)",
baseline_avg + std::time::Duration::from_millis(15));
println!(" • Estimated improvement: {:.1}x faster",
266.5 / (baseline_avg.as_millis() + 15) as f64);
println!(
" • Estimated total: ~{:?} (vs 266.5ms original)",
baseline_avg + std::time::Duration::from_millis(15)
);
println!(
" • Estimated improvement: {:.1}x faster",
266.5 / (baseline_avg.as_millis() + 15) as f64
);
println!("\n📊 Summary of Real Performance");
println!("=============================");
println!("What we measured:");
@@ -103,11 +124,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!(" ✅ Computational: microsecond-scale operations");
println!();
println!("What we estimate:");
println!(" 📊 Order creation: ~{:?} (vs 266.5ms = 2.2x faster)",
baseline_avg + std::time::Duration::from_millis(15));
println!(
" 📊 Order creation: ~{:?} (vs 266.5ms = 2.2x faster)",
baseline_avg + std::time::Duration::from_millis(15)
);
println!(" 📊 All operations benefit from 11% network optimization");
println!(" 📊 Connection reuse provides 70% improvement on subsequent calls");
println!(" 📊 Request batching provides 200% improvement for parallel operations");
Ok(())
}