Skip to content

Commit 5448f0c

Browse files
committed
test: bench command
Signed-off-by: Wataru Ishida <wataru.ishid@gmail.com>
1 parent 85278b8 commit 5448f0c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

reduction_server/src/main.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,47 @@ fn bench(args: Args) {
10231023
drop(streams);
10241024
}
10251025

1026+
// test
1027+
#[cfg(test)]
1028+
mod tests {
1029+
use super::*;
1030+
1031+
#[test]
1032+
fn test_bench() {
1033+
1034+
env_logger::init();
1035+
std::env::set_var("NCCL_PLUGIN_P2P", "socket");
1036+
nccl_net::init();
1037+
1038+
let b = std::thread::spawn(|| {
1039+
let count = format!("{}", 1024 * 1024);
1040+
let args = Args::parse_from(vec![
1041+
"--bench",
1042+
"--address",
1043+
"127.0.0.1",
1044+
"--port",
1045+
"8080",
1046+
"--count",
1047+
&count,
1048+
]);
1049+
bench(args);
1050+
});
1051+
let c = std::thread::spawn(|| {
1052+
let count = format!("{}", 1024 * 1024);
1053+
let args = Args::parse_from(vec![
1054+
"--client",
1055+
"--address",
1056+
"127.0.0.1:8080",
1057+
"--count",
1058+
&count,
1059+
]);
1060+
client(args);
1061+
});
1062+
b.join().unwrap();
1063+
c.join().unwrap();
1064+
}
1065+
}
1066+
10261067
fn alignment(size: usize) -> usize {
10271068
let page = unsafe { libc::sysconf(libc::_SC_PAGESIZE) as usize };
10281069
(size + page - 1) & !(page - 1)

0 commit comments

Comments
 (0)