Last active
January 1, 2024 21:35
-
-
Save afeistel/469ade1095106d7132cd0fbc9bdbe8af to your computer and use it in GitHub Desktop.
I used this to debug ruchei's performance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::{ | |
| sync::atomic::{AtomicBool, Ordering}, | |
| thread, | |
| time::Duration, | |
| }; | |
| static SAMPLE: AtomicBool = AtomicBool::new(false); | |
| fn set_sample(sample: bool) { | |
| SAMPLE.store(sample, Ordering::Release) | |
| } | |
| fn sample() -> bool { | |
| SAMPLE.load(Ordering::Acquire) | |
| } | |
| fn sample_thread() { | |
| let mut counts = Vec::new(); | |
| loop { | |
| for _ in 0..10 { | |
| let mut count = 0; | |
| for _ in 0..1000 { | |
| if sample() { | |
| count += 1; | |
| } | |
| thread::sleep(Duration::from_micros(100)); | |
| } | |
| counts.push(count); | |
| } | |
| eprintln!("sample: {counts:?}"); | |
| counts.clear(); | |
| } | |
| } | |
| pub fn start_sample() { | |
| thread::spawn(sample_thread); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the issue, in the end, was to do with
.incoming()in async-tungstenite