Clean readme, replace Arcs with leaked Boxes
This commit is contained in:
parent
ad2c0909b4
commit
a95efd9ed8
4 changed files with 19 additions and 35 deletions
|
|
@ -102,25 +102,24 @@ pub async fn play(
|
|||
) {
|
||||
// Semaphore used to limit the number of concurrent clients.
|
||||
// Its handle is released when the task panics.
|
||||
let limiter = Arc::new(Semaphore::new(concurrency));
|
||||
let counter = Arc::new(AtomicU32::new(0));
|
||||
let running = Arc::new(Mutex::new(HashSet::new()));
|
||||
let limiter: &'static _ = Box::leak(Box::new(Semaphore::new(concurrency)));
|
||||
let counter: &'static _ = Box::leak(Box::new(AtomicU32::new(0)));
|
||||
let running: &'static _ = Box::leak(Box::new(Mutex::new(HashSet::new())));
|
||||
let total = records.len() * repeat as usize;
|
||||
let connect_to = connect_to.to_socket_addrs().unwrap().next().unwrap();
|
||||
|
||||
let dummy_bytes = Arc::new(vec![0x42u8; 16 * 1024 * 1024]);
|
||||
let dummy_bytes: &'static _ = Box::leak(Box::new(vec![0x42u8; 16 * 1024 * 1024]));
|
||||
|
||||
let notify_socket = notify_addr.map(|notify_addr| {
|
||||
let socket = std::net::UdpSocket::bind("0.0.0.0:48567").unwrap();
|
||||
socket.connect(notify_addr).unwrap();
|
||||
Arc::new(socket)
|
||||
let socket: &'static _ = Box::leak(Box::new(socket));
|
||||
socket
|
||||
});
|
||||
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
|
||||
|
||||
tokio::spawn({
|
||||
let running = running.clone();
|
||||
let counter = counter.clone();
|
||||
async move {
|
||||
let mut last_count = 0;
|
||||
loop {
|
||||
|
|
@ -197,11 +196,7 @@ pub async fn play(
|
|||
let mut handles = Vec::new();
|
||||
for (conn_id, (server_name, records)) in records.iter() {
|
||||
let connector = TlsConnector::from(config.clone());
|
||||
let counter = counter.clone();
|
||||
let limiter = limiter.clone();
|
||||
let running = running.clone();
|
||||
let dummy_bytes = dummy_bytes.clone();
|
||||
let notify_socket = notify_socket.clone();
|
||||
handles.push(tokio::spawn(async move {
|
||||
let mut running_guard = running.lock().await;
|
||||
running_guard.insert(*conn_id);
|
||||
|
|
@ -294,11 +289,7 @@ pub async fn play(
|
|||
for _i in 0..repeat {
|
||||
let mut handles = Vec::new();
|
||||
for (conn_id, (_server_name, records)) in records.iter() {
|
||||
let counter = counter.clone();
|
||||
let limiter = limiter.clone();
|
||||
let running = running.clone();
|
||||
let dummy_bytes = dummy_bytes.clone();
|
||||
let notify_socket = notify_socket.clone();
|
||||
handles.push(tokio::spawn(async move {
|
||||
let mut running_guard = running.lock().await;
|
||||
running_guard.insert(*conn_id);
|
||||
|
|
@ -366,7 +357,7 @@ pub async fn play(
|
|||
println!("Client: {} / {}", cnt, total);
|
||||
}
|
||||
drop(limiter);
|
||||
if let Some(notify_socket) = ¬ify_socket {
|
||||
if let Some(notify_socket) = notify_socket {
|
||||
notify_socket.send(&cnt.to_be_bytes()).unwrap();
|
||||
}
|
||||
let mut running_guard = running.lock().await;
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ pub async fn play(
|
|||
}
|
||||
}
|
||||
|
||||
let response_map = Arc::new(response_map);
|
||||
let dummy_bytes = Arc::new(vec![0x42u8; 16 * 1024 * 1024]);
|
||||
let response_map: &'static _ = Box::leak(Box::new(response_map));
|
||||
let dummy_bytes: &'static _ = Box::leak(Box::new(vec![0x42u8; 16 * 1024 * 1024]));
|
||||
|
||||
if use_tls {
|
||||
let mut resolver = ResolvesServerCertUsingSni::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue