From a6096e84992aaa63f8dea812a6bf664988c8d58b Mon Sep 17 00:00:00 2001 From: Jonathan Reem Date: Tue, 9 Sep 2014 12:00:37 -0700 Subject: [PATCH] Fix server benchmark for Response representation changes. --- benches/server.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/benches/server.rs b/benches/server.rs index b40322bf..de9c3e8f 100644 --- a/benches/server.rs +++ b/benches/server.rs @@ -19,6 +19,7 @@ fn request(url: hyper::Url) { fn hyper_handle(mut incoming: hyper::server::Incoming) { for (_, mut res) in incoming { + let mut res = res.start().unwrap(); res.write(phrase).unwrap(); res.end().unwrap(); } @@ -56,9 +57,12 @@ impl Server for HttpServer { #[bench] fn bench_http(b: &mut Bencher) { - if unsafe { !created_http } { spawn(proc() { HttpServer.serve_forever() }); unsafe { created_http = true } } - // Mega hack because there is no way to wait for serve_forever to start: - std::io::timer::sleep(std::time::duration::Duration::seconds(1)); + if unsafe { !created_http } { + spawn(proc() { HttpServer.serve_forever() }); + unsafe { created_http = true } + // Mega hack because there is no way to wait for serve_forever to start: + std::io::timer::sleep(std::time::duration::Duration::seconds(1)); + } let url = hyper::Url::parse("http://localhost:4000").unwrap(); b.iter(|| request(url.clone()));