Skip to content

Instantly share code, notes, and snippets.

let mut file = try!(File::open(fname).context(fname));
try!(file.read_to_string(&mut buf).context(fname));
try!(buf.parse().context(fname))
enum Error {
Io(io::Error),
Parse(ParseIntError),
}
// ...
try!(File::open(fname)
.and_then(|mut f| f.read_to_string(&mut buf))
.map_err(|e| Error::Io(e, fname.to_path_buf())));
let x: u64 = try!(buf.parse()
.map_err(|e| Error::Parse(e, fname.to_path_buf())));
#[macro_use(quick_error)] extern crate quick_error;
use std::io::{self, stderr, Read, Write};
use std::fs::File;
use std::env;
use std::num::ParseIntError;
use std::path::{Path, PathBuf};
quick_error! {
#[derive(Debug)]
#[macro_use(quick_error)] extern crate quick_error;
use std::io::{self, stderr, Read, Write};
use std::fs::File;
use std::env;
use std::num::ParseIntError;
use std::path::{Path, PathBuf};
use quick_error::ResultExt;
#[macro_use(quick_error)] extern crate quick_error;
use std::io::{self, stderr, Read, Write};
use std::fs::File;
use std::env;
use std::num::ParseIntError;
use std::path::{Path, PathBuf};
use quick_error::ResultExt;
--- examples/serve.rs 2016-03-29 00:14:50.712643740 +0300
+++ examples/serve_sendfile.rs 2016-04-05 00:13:24.651021841 +0300
@@ -14,7 +14,8 @@
enum Http {
ReadHeaders,
- SendResponse,
+ SendingFile { offset: u64 },
+ BodySent,
}
> ~/wrk -t 2 -c 20 -d 60 http://localhost:3000 --latency
Running 1m test @ http://localhost:3000
2 threads and 20 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 0.87ms 26.71us 1.62ms 94.77%
Req/Sec 11.44k 279.33 11.71k 93.26%
Latency Distribution
50% 0.86ms
75% 0.87ms
90% 0.88ms
> ~/wrk -t 2 -c 20 -d 60 http://hostname:3000 --latency
Running 1m test @ http://hostname:3000
2 threads and 20 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 33.21ms 1.15ms 47.44ms 87.93%
Req/Sec 300.70 9.00 323.00 78.17%
Latency Distribution
50% 33.13ms
75% 33.60ms
90% 34.08ms
> ~/wrk -t 2 -c 20 -d 60 http://hostname:3000 --latency
Running 1m test @ http://hostname:3000
2 threads and 20 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 18.97ms 5.30ms 237.70ms 96.60%
Req/Sec 534.52 23.46 1.02k 80.10%
Latency Distribution
50% 18.70ms
75% 19.40ms
90% 21.02ms
> ~/wrk -t 2 -c 20 -d 60 http://hostname:3000 --latency
Running 1m test @ http://hostname:3000
2 threads and 20 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 451.75us 73.89us 2.42ms 78.56%
Req/Sec 18.19k 1.54k 28.56k 83.44%
Latency Distribution
50% 441.00us
75% 488.00us
90% 545.00us