Skip to content

Commit

Permalink
feat: update resource clean up and warm up
Browse files Browse the repository at this point in the history
  • Loading branch information
tombelieber authored Jan 24, 2025
1 parent d3aadae commit cf22eab
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions examples/o1_synchronizer_market_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,20 @@ fn main() {
// `shm_path` is now a PathBuf
let shm_path = Arc::new(shm_path); // Arc<PathBuf>

// 在 main 开头清理旧共享内存:
let _ = fs::remove_file(&*shm_path);

// 添加预热迭代(不记录延迟):
for _ in 0..1000 {
synchronizer.write(&data, ...).unwrap();
}
// 预热阶段(不记录延迟)
const WARMUP_ITERATIONS: usize = 10_000;
let mut synchronizer = MySyncType::with_params(...);
for _ in 0..WARMUP_ITERATIONS {
synchronizer.write(&dummy_data, ...).unwrap();
let _ = synchronizer.read::<Data>();
}

// 重置同步器,确保正式测试从干净状态开始
drop(synchronizer);
let _ = fs::remove_file(&shm_path);
let synchronizer = MySyncType::with_params(...);



// Add a shared 'done' flag so readers can stop
Expand Down

0 comments on commit cf22eab

Please sign in to comment.