-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathapi_throughput.rs
48 lines (41 loc) · 1.05 KB
/
api_throughput.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#![feature(test)]
extern crate api;
extern crate test;
extern crate protobuf;
#[cfg(test)]
mod tests {
use api::service::*;
use api::service_capnp::*;
use protobuf::Message;
use test::{black_box, Bencher};
fn create_proto_message(){
let mut o = FileOperation::new();
let mut stat = StatRequest::new();
stat.set_gfid("foo".to_string());
o.set_stat_req(stat);
let encoded = o.write_to_bytes().unwrap();
let mut m = Message::new();
let msg = m.merge_from_bytes(&encoded).unwrap();
}
fn create_cap_message(){
//
}
#[bench]
fn bench_protobuf(b: &mut Bencher) {
b.iter(|| {
// Inner closure, the actual test
for i in 1..100 {
black_box(create_proto_message());
}
});
}
#[bench]
fn bench_capnp(b: &mut Bencher) {
b.iter(|| {
// Inner closure, the actual test
for i in 1..100 {
black_box(create_cap_message());
}
});
}
}