From aaf8a6e108a6080cdd47983909e90a60c1d92aea Mon Sep 17 00:00:00 2001 From: Moritz Ulrich Date: Sat, 30 Jul 2016 09:01:13 +0200 Subject: [PATCH 1/2] tcp-stress-test: Factor out thread count as constant. --- src/test/run-pass/tcp-stress.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/run-pass/tcp-stress.rs b/src/test/run-pass/tcp-stress.rs index dfc86497c9652..e5b418bb733cf 100644 --- a/src/test/run-pass/tcp-stress.rs +++ b/src/test/run-pass/tcp-stress.rs @@ -21,6 +21,8 @@ use std::sync::mpsc::channel; use std::time::Duration; use std::thread::{self, Builder}; +const TARGET_CNT: usize = 1000; + fn main() { // This test has a chance to time out, try to not let it time out thread::spawn(move|| -> () { @@ -42,8 +44,9 @@ fn main() { }); let (tx, rx) = channel(); + let mut spawned_cnt = 0; - for _ in 0..1000 { + for _ in 0..TARGET_CNT { let tx = tx.clone(); let res = Builder::new().stack_size(64 * 1024).spawn(move|| { match TcpStream::connect(addr) { @@ -66,6 +69,6 @@ fn main() { for _ in 0..spawned_cnt { rx.recv().unwrap(); } - assert_eq!(spawned_cnt, 1000); + assert_eq!(spawned_cnt, TARGET_CNT); process::exit(0); } From 3ea293ddf2af66c9a2e720ce3139aed75787d890 Mon Sep 17 00:00:00 2001 From: Moritz Ulrich Date: Mon, 1 Aug 2016 09:43:19 +0200 Subject: [PATCH 2/2] tcp-stress-test.rs: Only spawn 200 threads. --- src/test/run-pass/tcp-stress.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-pass/tcp-stress.rs b/src/test/run-pass/tcp-stress.rs index e5b418bb733cf..0ba019c591c19 100644 --- a/src/test/run-pass/tcp-stress.rs +++ b/src/test/run-pass/tcp-stress.rs @@ -21,7 +21,7 @@ use std::sync::mpsc::channel; use std::time::Duration; use std::thread::{self, Builder}; -const TARGET_CNT: usize = 1000; +const TARGET_CNT: usize = 200; fn main() { // This test has a chance to time out, try to not let it time out