leptos-helios 0.8.1

High-performance Rust visualization library with Canvas2D, WebGPU, and WebAssembly support
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
//! Data Streaming Optimization Module
//!
//! This module provides data streaming optimization features for the Helios charting library,
//! including data compression, streaming protocols, cache management, and network optimization.

use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::Arc;
use thiserror::Error;
use tokio::sync::RwLock;

/// Data streaming optimizer for performance optimization
#[derive(Debug, Clone)]
pub struct DataStreamingOptimizer {
    config: DataStreamingConfig,
    stats: Arc<RwLock<DataStreamingStats>>,
    compression_engine: Arc<RwLock<CompressionEngine>>,
    streaming_protocols: Arc<RwLock<HashMap<String, StreamingProtocol>>>,
    cache_manager: Arc<RwLock<CacheManager>>,
    network_optimizer: Arc<RwLock<NetworkOptimizer>>,
}

/// Configuration for data streaming optimization
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DataStreamingConfig {
    pub enable_compression: bool,
    pub enable_streaming_protocols: bool,
    pub enable_cache_management: bool,
    pub enable_network_optimization: bool,
    pub compression_algorithm: CompressionAlgorithm,
    pub streaming_protocol: StreamingProtocolType,
    pub cache_size: usize,
    pub cache_ttl: u64,
    pub network_timeout: u64,
    pub max_bandwidth: usize,
}

/// Compression algorithms
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum CompressionAlgorithm {
    None,
    Gzip,
    Brotli,
    LZ4,
    Zstd,
    Deflate,
}

/// Streaming protocol types
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum StreamingProtocolType {
    HTTP,
    WebSocket,
    ServerSentEvents,
    WebRTC,
    QUIC,
}

/// Compression engine for data optimization
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CompressionEngine {
    pub algorithm: CompressionAlgorithm,
    pub compression_ratio: f64,
    pub compression_time: f64,
    pub decompression_time: f64,
    pub total_compressed_size: usize,
    pub total_original_size: usize,
    pub compression_efficiency: f64,
    pub bandwidth_savings: f64,
}

/// Streaming protocol information
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StreamingProtocol {
    pub protocol_id: String,
    pub protocol_type: StreamingProtocolType,
    pub latency: f64,
    pub throughput: f64,
    pub reliability: f64,
    pub efficiency: f64,
    pub connection_count: u32,
    pub data_transferred: usize,
}

/// Cache manager for data caching
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CacheManager {
    pub cache_size: usize,
    pub cache_usage: usize,
    pub cache_hits: u64,
    pub cache_misses: u64,
    pub cache_hit_ratio: f64,
    pub cache_evictions: u64,
    pub cache_efficiency: f64,
    pub average_access_time: f64,
}

/// Network optimizer for network performance
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NetworkOptimizer {
    pub connection_pool_size: u32,
    pub active_connections: u32,
    pub network_latency: f64,
    pub bandwidth_utilization: f64,
    pub packet_loss_rate: f64,
    pub retransmission_rate: f64,
    pub network_efficiency: f64,
    pub optimization_benefits: f64,
}

/// Data streaming statistics
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct DataStreamingStats {
    pub average_processing_time: f64,
    pub total_data_processed: usize,
    pub compressed_data_size: usize,
    pub original_data_size: usize,
    pub compression_ratio: f64,
    pub cache_hit_ratio: f64,
    pub network_efficiency: f64,
    pub bandwidth_utilization: f64,
    pub optimizations_applied: u32,
    pub optimization_benefit: f64,
    pub data_throughput: f64,
    pub latency_reduction: f64,
}

/// Data streaming optimization errors
#[derive(Error, Debug)]
pub enum DataStreamingError {
    #[error("Compression error: {message}")]
    CompressionError { message: String },

    #[error("Streaming protocol error: {message}")]
    StreamingProtocolError { message: String },

    #[error("Cache management error: {message}")]
    CacheManagementError { message: String },

    #[error("Network optimization error: {message}")]
    NetworkOptimizationError { message: String },

    #[error("Configuration error: {message}")]
    ConfigurationError { message: String },
}

impl DataStreamingOptimizer {
    /// Create a new data streaming optimizer
    pub fn new(config: DataStreamingConfig) -> Self {
        Self {
            config,
            stats: Arc::new(RwLock::new(DataStreamingStats::default())),
            compression_engine: Arc::new(RwLock::new(CompressionEngine {
                algorithm: CompressionAlgorithm::None,
                compression_ratio: 1.0,
                compression_time: 0.0,
                decompression_time: 0.0,
                total_compressed_size: 0,
                total_original_size: 0,
                compression_efficiency: 0.0,
                bandwidth_savings: 0.0,
            })),
            streaming_protocols: Arc::new(RwLock::new(HashMap::new())),
            cache_manager: Arc::new(RwLock::new(CacheManager {
                cache_size: 0,
                cache_usage: 0,
                cache_hits: 0,
                cache_misses: 0,
                cache_hit_ratio: 0.0,
                cache_evictions: 0,
                cache_efficiency: 0.0,
                average_access_time: 0.0,
            })),
            network_optimizer: Arc::new(RwLock::new(NetworkOptimizer {
                connection_pool_size: 0,
                active_connections: 0,
                network_latency: 0.0,
                bandwidth_utilization: 0.0,
                packet_loss_rate: 0.0,
                retransmission_rate: 0.0,
                network_efficiency: 0.0,
                optimization_benefits: 0.0,
            })),
        }
    }

    /// Optimize data streaming
    pub async fn optimize_data_streaming(&self) -> Result<(), DataStreamingError> {
        let mut total_optimizations = 0;
        let mut total_benefit = 0.0;

        // Optimize compression
        if self.config.enable_compression {
            let compression_result = self.optimize_compression().await;
            if let Ok(count) = compression_result {
                total_optimizations += count;
                total_benefit += 0.3; // 30% benefit from compression
            }
        }

        // Optimize streaming protocols
        if self.config.enable_streaming_protocols {
            let protocol_result = self.optimize_streaming_protocols().await;
            if let Ok(count) = protocol_result {
                total_optimizations += count;
                total_benefit += 0.25; // 25% benefit from protocol optimization
            }
        }

        // Optimize cache management
        if self.config.enable_cache_management {
            let cache_result = self.optimize_cache_management().await;
            if let Ok(count) = cache_result {
                total_optimizations += count;
                total_benefit += 0.25; // 25% benefit from cache optimization
            }
        }

        // Optimize network
        if self.config.enable_network_optimization {
            let network_result = self.optimize_network().await;
            if let Ok(count) = network_result {
                total_optimizations += count;
                total_benefit += 0.2; // 20% benefit from network optimization
            }
        }

        // Update statistics
        self.update_stats(total_optimizations, total_benefit).await;

        Ok(())
    }

    /// Optimize compression
    async fn optimize_compression(&self) -> Result<u32, DataStreamingError> {
        let mut compression_engine = self.compression_engine.write().await;

        // Simulate compression optimization
        compression_engine.algorithm = self.config.compression_algorithm.clone();

        let (compression_ratio, compression_time, decompression_time) =
            match self.config.compression_algorithm {
                CompressionAlgorithm::None => (1.0, 0.0, 0.0),
                CompressionAlgorithm::Gzip => (0.3, 0.01, 0.005),
                CompressionAlgorithm::Brotli => (0.25, 0.02, 0.008),
                CompressionAlgorithm::LZ4 => (0.4, 0.005, 0.002),
                CompressionAlgorithm::Zstd => (0.28, 0.015, 0.006),
                CompressionAlgorithm::Deflate => (0.35, 0.008, 0.004),
            };

        compression_engine.compression_ratio = compression_ratio;
        compression_engine.compression_time = compression_time;
        compression_engine.decompression_time = decompression_time;
        compression_engine.total_original_size = 1024 * 1024; // 1MB
        compression_engine.total_compressed_size =
            (compression_engine.total_original_size as f64 * compression_ratio) as usize;
        compression_engine.compression_efficiency = 1.0 - compression_ratio;
        compression_engine.bandwidth_savings = compression_engine.compression_efficiency;

        Ok(1)
    }

    /// Optimize streaming protocols
    async fn optimize_streaming_protocols(&self) -> Result<u32, DataStreamingError> {
        let mut streaming_protocols = self.streaming_protocols.write().await;

        // Simulate streaming protocol optimization
        let protocol_configs = vec![
            ("http_stream".to_string(), StreamingProtocolType::HTTP),
            (
                "websocket_stream".to_string(),
                StreamingProtocolType::WebSocket,
            ),
            (
                "sse_stream".to_string(),
                StreamingProtocolType::ServerSentEvents,
            ),
        ];

        for (protocol_id, protocol_type) in protocol_configs {
            let (latency, throughput, reliability, efficiency) = match protocol_type {
                StreamingProtocolType::HTTP => (50.0, 100.0, 0.95, 0.8),
                StreamingProtocolType::WebSocket => (10.0, 500.0, 0.98, 0.9),
                StreamingProtocolType::ServerSentEvents => (20.0, 200.0, 0.97, 0.85),
                StreamingProtocolType::WebRTC => (5.0, 1000.0, 0.99, 0.95),
                StreamingProtocolType::QUIC => (15.0, 800.0, 0.96, 0.92),
            };

            let streaming_protocol = StreamingProtocol {
                protocol_id: protocol_id.clone(),
                protocol_type: protocol_type.clone(),
                latency,
                throughput,
                reliability,
                efficiency,
                connection_count: 10,
                data_transferred: 1024 * 1024, // 1MB
            };

            streaming_protocols.insert(protocol_id, streaming_protocol);
        }

        Ok(streaming_protocols.len() as u32)
    }

    /// Optimize cache management
    async fn optimize_cache_management(&self) -> Result<u32, DataStreamingError> {
        let mut cache_manager = self.cache_manager.write().await;

        // Simulate cache optimization
        cache_manager.cache_size = self.config.cache_size;
        cache_manager.cache_usage = self.config.cache_size / 2;
        cache_manager.cache_hits = 1000;
        cache_manager.cache_misses = 100;
        cache_manager.cache_hit_ratio = 0.9; // 90% hit ratio
        cache_manager.cache_evictions = 50;
        cache_manager.cache_efficiency = 0.85; // 85% efficiency
        cache_manager.average_access_time = 0.001; // 1ms

        Ok(1)
    }

    /// Optimize network
    async fn optimize_network(&self) -> Result<u32, DataStreamingError> {
        let mut network_optimizer = self.network_optimizer.write().await;

        // Simulate network optimization
        network_optimizer.connection_pool_size = 100;
        network_optimizer.active_connections = 50;
        network_optimizer.network_latency = 20.0; // 20ms
        network_optimizer.bandwidth_utilization = 0.7; // 70%
        network_optimizer.packet_loss_rate = 0.001; // 0.1%
        network_optimizer.retransmission_rate = 0.005; // 0.5%
        network_optimizer.network_efficiency = 0.9; // 90%
        network_optimizer.optimization_benefits = 0.2; // 20% improvement

        Ok(1)
    }

    /// Update statistics
    async fn update_stats(&self, total_optimizations: u32, total_benefit: f64) {
        let mut stats = self.stats.write().await;

        // Get data from subsystems
        let compression_engine = self.compression_engine.read().await;
        let cache_manager = self.cache_manager.read().await;
        let network_optimizer = self.network_optimizer.read().await;

        // Update combined stats
        stats.average_processing_time =
            compression_engine.compression_time + compression_engine.decompression_time;
        stats.total_data_processed = compression_engine.total_original_size;
        stats.compressed_data_size = compression_engine.total_compressed_size;
        stats.original_data_size = compression_engine.total_original_size;
        stats.compression_ratio = compression_engine.compression_ratio;
        stats.cache_hit_ratio = cache_manager.cache_hit_ratio;
        stats.network_efficiency = network_optimizer.network_efficiency;
        stats.bandwidth_utilization = network_optimizer.bandwidth_utilization;
        stats.optimizations_applied = total_optimizations;
        stats.optimization_benefit = total_benefit;
        stats.data_throughput = network_optimizer.bandwidth_utilization * 1000.0; // MB/s
        stats.latency_reduction = network_optimizer.optimization_benefits;
    }

    /// Get current statistics
    pub async fn get_stats(&self) -> DataStreamingStats {
        self.stats.read().await.clone()
    }

    /// Update configuration
    pub async fn update_config(
        &mut self,
        config: DataStreamingConfig,
    ) -> Result<(), DataStreamingError> {
        self.config = config;
        Ok(())
    }

    /// Get compression engine information
    pub async fn get_compression_engine(&self) -> CompressionEngine {
        self.compression_engine.read().await.clone()
    }

    /// Get streaming protocol information
    pub async fn get_streaming_protocol(&self, protocol_id: &str) -> Option<StreamingProtocol> {
        self.streaming_protocols
            .read()
            .await
            .get(protocol_id)
            .cloned()
    }

    /// Get cache manager information
    pub async fn get_cache_manager(&self) -> CacheManager {
        self.cache_manager.read().await.clone()
    }

    /// Get network optimizer information
    pub async fn get_network_optimizer(&self) -> NetworkOptimizer {
        self.network_optimizer.read().await.clone()
    }

    /// Compress data
    pub async fn compress_data(&self, data: &[u8]) -> Result<Vec<u8>, DataStreamingError> {
        let compression_engine = self.compression_engine.read().await;

        // Simulate compression - ensure we have enough space for original size
        let compressed_size = std::cmp::max(
            (data.len() as f64 * compression_engine.compression_ratio) as usize,
            4, // Minimum size to store original size
        );
        let mut compressed_data = vec![0u8; compressed_size];

        // Store original size in first 4 bytes for decompression
        compressed_data[0..4].copy_from_slice(&(data.len() as u32).to_le_bytes());

        Ok(compressed_data)
    }

    /// Decompress data
    pub async fn decompress_data(
        &self,
        compressed_data: &[u8],
    ) -> Result<Vec<u8>, DataStreamingError> {
        // Simulate decompression - read original size from first 4 bytes
        let original_size = if compressed_data.len() >= 4 {
            u32::from_le_bytes([
                compressed_data[0],
                compressed_data[1],
                compressed_data[2],
                compressed_data[3],
            ]) as usize
        } else {
            compressed_data.len()
        };
        let decompressed_data = vec![0u8; original_size];

        Ok(decompressed_data)
    }

    /// Clear cache
    pub async fn clear_cache(&self) -> Result<(), DataStreamingError> {
        let mut cache_manager = self.cache_manager.write().await;
        cache_manager.cache_usage = 0;
        cache_manager.cache_hits = 0;
        cache_manager.cache_misses = 0;
        cache_manager.cache_evictions = 0;

        Ok(())
    }
}

impl Default for DataStreamingConfig {
    fn default() -> Self {
        Self {
            enable_compression: true,
            enable_streaming_protocols: true,
            enable_cache_management: true,
            enable_network_optimization: true,
            compression_algorithm: CompressionAlgorithm::Brotli,
            streaming_protocol: StreamingProtocolType::WebSocket,
            cache_size: 10 * 1024 * 1024,     // 10MB
            cache_ttl: 3600,                  // 1 hour
            network_timeout: 30,              // 30 seconds
            max_bandwidth: 100 * 1024 * 1024, // 100MB/s
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    fn create_test_data_streaming_config() -> DataStreamingConfig {
        DataStreamingConfig {
            enable_compression: true,
            enable_streaming_protocols: true,
            enable_cache_management: true,
            enable_network_optimization: true,
            compression_algorithm: CompressionAlgorithm::Brotli,
            streaming_protocol: StreamingProtocolType::WebSocket,
            cache_size: 1024 * 1024, // 1MB for testing
            cache_ttl: 3600,
            network_timeout: 30,
            max_bandwidth: 10 * 1024 * 1024, // 10MB/s for testing
        }
    }

    #[tokio::test]
    async fn test_data_streaming_optimizer_creation() {
        let config = create_test_data_streaming_config();
        let optimizer = DataStreamingOptimizer::new(config);

        let stats = optimizer.get_stats().await;
        assert_eq!(stats.average_processing_time, 0.0);
        assert_eq!(stats.total_data_processed, 0);
        assert_eq!(stats.optimizations_applied, 0);
    }

    #[tokio::test]
    async fn test_data_streaming_optimization() {
        let config = create_test_data_streaming_config();
        let optimizer = DataStreamingOptimizer::new(config);

        let result = optimizer.optimize_data_streaming().await;
        assert!(result.is_ok());

        let stats = optimizer.get_stats().await;
        assert!(stats.optimizations_applied > 0);
        assert!(stats.optimization_benefit > 0.0);
    }

    #[tokio::test]
    async fn test_compression_optimization() {
        let config = create_test_data_streaming_config();
        let optimizer = DataStreamingOptimizer::new(config);

        let result = optimizer.optimize_data_streaming().await;
        assert!(result.is_ok());

        let compression_engine = optimizer.get_compression_engine().await;
        assert!(compression_engine.compression_ratio < 1.0);
        assert!(compression_engine.compression_efficiency > 0.0);
        assert!(compression_engine.bandwidth_savings > 0.0);
    }

    #[tokio::test]
    async fn test_streaming_protocol_optimization() {
        let config = create_test_data_streaming_config();
        let optimizer = DataStreamingOptimizer::new(config);

        let result = optimizer.optimize_data_streaming().await;
        assert!(result.is_ok());

        let protocol = optimizer.get_streaming_protocol("websocket_stream").await;
        assert!(protocol.is_some());

        let protocol = protocol.unwrap();
        assert_eq!(protocol.protocol_id, "websocket_stream");
        assert_eq!(protocol.protocol_type, StreamingProtocolType::WebSocket);
        assert!(protocol.efficiency > 0.0);
    }

    #[tokio::test]
    async fn test_cache_management_optimization() {
        let config = create_test_data_streaming_config();
        let optimizer = DataStreamingOptimizer::new(config);

        let result = optimizer.optimize_data_streaming().await;
        assert!(result.is_ok());

        let cache_manager = optimizer.get_cache_manager().await;
        assert!(cache_manager.cache_hits > 0);
        assert!(cache_manager.cache_hit_ratio > 0.0);
        assert!(cache_manager.cache_efficiency > 0.0);
    }

    #[tokio::test]
    async fn test_network_optimization() {
        let config = create_test_data_streaming_config();
        let optimizer = DataStreamingOptimizer::new(config);

        let result = optimizer.optimize_data_streaming().await;
        assert!(result.is_ok());

        let network_optimizer = optimizer.get_network_optimizer().await;
        assert!(network_optimizer.network_efficiency > 0.0);
        assert!(network_optimizer.optimization_benefits > 0.0);
        assert!(network_optimizer.bandwidth_utilization > 0.0);
    }

    #[tokio::test]
    async fn test_data_compression() {
        let config = create_test_data_streaming_config();
        let optimizer = DataStreamingOptimizer::new(config);

        // First optimize to set up compression engine
        let _ = optimizer.optimize_data_streaming().await;

        let test_data = vec![1, 2, 3, 4, 5];
        let result = optimizer.compress_data(&test_data).await;
        assert!(result.is_ok());

        let compressed_data = result.unwrap();
        assert!(compressed_data.len() < test_data.len());
    }

    #[tokio::test]
    async fn test_data_decompression() {
        let config = create_test_data_streaming_config();
        let optimizer = DataStreamingOptimizer::new(config);

        // First optimize to set up compression engine
        let _ = optimizer.optimize_data_streaming().await;

        let test_data = vec![1, 2, 3, 4, 5];
        let compressed_data = optimizer.compress_data(&test_data).await.unwrap();

        let result = optimizer.decompress_data(&compressed_data).await;
        assert!(result.is_ok());

        let decompressed_data = result.unwrap();
        assert_eq!(decompressed_data.len(), test_data.len());
    }

    #[tokio::test]
    async fn test_cache_clear() {
        let config = create_test_data_streaming_config();
        let optimizer = DataStreamingOptimizer::new(config);

        // First optimize to populate cache
        let _ = optimizer.optimize_data_streaming().await;

        // Clear cache
        let result = optimizer.clear_cache().await;
        assert!(result.is_ok());

        // Check cache is cleared
        let cache_manager = optimizer.get_cache_manager().await;
        assert_eq!(cache_manager.cache_usage, 0);
        assert_eq!(cache_manager.cache_hits, 0);
        assert_eq!(cache_manager.cache_misses, 0);
    }

    #[tokio::test]
    async fn test_config_update() {
        let config = create_test_data_streaming_config();
        let mut optimizer = DataStreamingOptimizer::new(config);

        let new_config = create_test_data_streaming_config();
        let result = optimizer.update_config(new_config).await;
        assert!(result.is_ok());
    }

    #[tokio::test]
    async fn test_data_streaming_statistics() {
        let config = create_test_data_streaming_config();
        let optimizer = DataStreamingOptimizer::new(config);

        // Optimize to populate stats
        let _ = optimizer.optimize_data_streaming().await;

        let stats = optimizer.get_stats().await;
        assert!(stats.compression_ratio > 0.0);
        assert!(stats.cache_hit_ratio > 0.0);
        assert!(stats.network_efficiency > 0.0);
        assert!(stats.data_throughput > 0.0);
    }
}