Skip to content

Commit

Permalink
bench client request
Browse files Browse the repository at this point in the history
  • Loading branch information
Covertness committed Jul 25, 2015
1 parent 689aefa commit 23ef871
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ addons:

# run builds for both all the trains
rust:
- nightly
- beta
- stable

Expand All @@ -23,7 +24,7 @@ script:
- |
travis-cargo build &&
travis-cargo test &&
travis-cargo bench &&
travis-cargo --only nightly bench &&
travis-cargo --only stable doc
after_success:
# upload the documentation from the build with beta (automatically only actually
Expand Down
26 changes: 26 additions & 0 deletions benches/client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#![feature(test)]

extern crate test;
extern crate coap;

use test::Bencher;
use coap::packet::*;
use coap::CoAPClient;

#[bench]
fn bench_client_request(b: &mut Bencher) {
let addr = "127.0.0.1:5683";
let request = "test";
let mut packet = Packet::new();
packet.header.set_version(1);
packet.header.set_type(PacketType::Confirmable);
packet.header.set_code("0.01");
packet.header.set_message_id(1);
packet.set_token(vec!(0x51, 0x55, 0x77, 0xE8));
packet.add_option(OptionType::UriPath, request.to_string().into_bytes());

b.iter(|| {
let client = CoAPClient::new(addr).unwrap();
client.send(&packet).unwrap();
});
}

0 comments on commit 23ef871

Please sign in to comment.