Fix server benchmark for Response representation changes.

This commit is contained in:
Jonathan Reem
2014-09-09 12:00:37 -07:00
parent 29cf174a06
commit a6096e8499

View File

@@ -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 } }
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()));