fix: resolve all remaining clippy warnings in examples and benchmarks including unused imports, variables, empty println statements, and enum naming conventions

This commit is contained in:
floor-licker
2025-12-04 07:37:40 -05:00
parent 3742a5b864
commit 88f116511c
20 changed files with 63 additions and 63 deletions
+1 -1
View File
@@ -185,7 +185,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Collect some samples
for i in 0..5 {
let start = Instant::now();
if let Ok(_) = client.get_server_time().await {
if (client.get_server_time().await).is_ok() {
let duration = start.elapsed();
adaptive_timeout.add_sample(duration);
if i < 3 {
+1 -1
View File
@@ -33,7 +33,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
for i in 0..3 {
let start = Instant::now();
match client.create_or_derive_api_key(None).await {
Ok(creds) => {
Ok(_creds) => {
let duration = start.elapsed();
setup_times.push(duration);
println!(" Run {}: ✅ API key setup in {:?}", i+1, duration);
+1 -1
View File
@@ -151,7 +151,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("• Fixed-point arithmetic in hot paths");
println!("• Zero-allocation order book operations");
println!("• Cache-friendly memory layouts");
println!("");
println!();
println!("🔬 Run `cargo bench` for detailed criterion benchmarks");
println!("📊 Run `./scripts/benchmark_comparison.sh` for comprehensive analysis");
+2 -1
View File
@@ -42,6 +42,7 @@ use tokio::time::sleep;
use tracing::{error, info, debug};
/// Comprehensive demo showcasing all polyfill-rs functionality
#[allow(dead_code)]
pub struct PolyfillDemo {
/// Basic HTTP client
client: ClobClient,
@@ -513,7 +514,7 @@ impl PolyfillDemo {
if rand::random::<bool>() {
Ok("Success!")
} else {
Err(PolyfillError::network("Simulated network error", std::io::Error::new(std::io::ErrorKind::Other, "Simulated error")))
Err(PolyfillError::network("Simulated network error", std::io::Error::other("Simulated error")))
}
};
+1 -1
View File
@@ -53,7 +53,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("==============================================");
println!("Comparing with polymarket-rs-client baseline:");
println!(" 88,053 allocs, 81,823 frees, 15,945,966 bytes allocated");
println!("");
println!();
// Load environment variables
dotenv::dotenv().ok();
+1 -1
View File
@@ -110,7 +110,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("• Processing cached/local data");
println!("• Running in co-located environments");
println!("• Performing high-frequency operations");
println!("");
println!();
println!("For fair comparison with polymarket-rs-client:");
println!("• Run from same geographic location");
println!("• Use same network conditions");
+4 -6
View File
@@ -1,6 +1,4 @@
use polyfill_rs::{ClobClient, OrderArgs, Side};
use rust_decimal::Decimal;
use std::str::FromStr;
use polyfill_rs::ClobClient;
use std::time::Instant;
#[tokio::main]
@@ -19,7 +17,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!(" 1. Private key for EIP-712 signing");
println!(" 2. Proper client initialization with credentials");
println!(" 3. Valid market context for orders");
println!("");
println!();
// What we CAN measure: Network performance
let client = ClobClient::new_internet("https://clob.polymarket.com");
@@ -86,7 +84,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Based on our network measurements:");
println!(" • Network baseline: {:?}", baseline_avg);
println!(" • Market data: {:?} (3.8x faster than original)", market_avg);
println!("");
println!();
println!("For order creation (266.5ms original):");
println!(" • Network component: ~{:?} (measured)", baseline_avg);
@@ -103,7 +101,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!(" ✅ Network baseline: {:?}", baseline_avg);
println!(" ✅ Market data: {:?} (3.8x faster)", market_avg);
println!(" ✅ Computational: microsecond-scale operations");
println!("");
println!();
println!("What we estimate:");
println!(" 📊 Order creation: ~{:?} (vs 266.5ms = 2.2x faster)",
baseline_avg + std::time::Duration::from_millis(15));
+2 -7
View File
@@ -5,7 +5,6 @@
use polyfill_rs::{ClobClient, Side, Result, PolyfillError};
use rust_decimal::Decimal;
use std::str::FromStr;
use tokio::time::{sleep, Duration};
use tracing::{info, error, warn};
@@ -67,7 +66,7 @@ async fn test_connectivity(client: &ClobClient) -> Result<()> {
// Test /ok endpoint
let is_ok = client.get_ok().await;
if !is_ok {
return Err(PolyfillError::network("API not responding", std::io::Error::new(std::io::ErrorKind::Other, "API not responding")));
return Err(PolyfillError::network("API not responding", std::io::Error::other("API not responding")));
}
info!(" /ok endpoint responding");
@@ -81,11 +80,7 @@ async fn test_connectivity(client: &ClobClient) -> Result<()> {
.unwrap()
.as_secs();
let time_diff = if server_time > current_time {
server_time - current_time
} else {
current_time - server_time
};
let time_diff = server_time.abs_diff(current_time);
if time_diff > 86400 { // 24 hours
warn!(" Server time seems off (diff: {} seconds)", time_diff);
+2 -2
View File
@@ -112,7 +112,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// First, try to create or derive API key
match client.create_or_derive_api_key(None).await {
Ok(creds) => {
Ok(_creds) => {
println!(" 🔑 API credentials set up successfully");
// Now test order creation
@@ -127,7 +127,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let start = Instant::now();
match client.create_order(&order_args, None, None, None).await {
Ok(order) => {
Ok(_order) => {
let duration = start.elapsed();
times.push(duration);
if i < 2 {
+1 -1
View File
@@ -322,7 +322,7 @@ impl MockMarketData {
// Generate random price movement
let random_factor = Decimal::from(rand::random::<i64>() % 100 - 50) / Decimal::from(100);
let volatility_f64 = self.volatility.to_f64().unwrap_or(0.01);
let _volatility_f64 = self.volatility.to_f64().unwrap_or(0.01);
let price_change = random_factor * Decimal::from(2) * self.volatility;
let new_price = self.base_price * (Decimal::from(1) + price_change);