Navigation Menu

Skip to content

Commit

Permalink
Merge #98
Browse files Browse the repository at this point in the history
98: 45 add kcov r=TimonPost,LucioFranco a=fhaynes

Experiment in adding kcov reports. relates to #45 

Co-authored-by: Fletcher Haynes <fletcher@capitalprawn.com>
  • Loading branch information
bors[bot] and fhaynes committed Nov 11, 2018
2 parents d086933 + c64ff42 commit 46899b4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
27 changes: 27 additions & 0 deletions .travis.yml
Expand Up @@ -27,6 +27,33 @@ matrix:
- rust: beta
fast_finish: true

addons:
apt:
packages:
- libcurl4-openssl-dev
- libelf-dev
- libdw-dev
- cmake
- gcc
- binutils-dev
- libiberty-dev

script:
- cargo clippy -- -D warnings
- cargo test --verbose --all --all-features

after_success: |
wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
tar xzf master.tar.gz &&
cd kcov-master &&
mkdir build &&
cd build &&
cmake .. &&
make &&
make install DESTDIR=../../kcov-build &&
cd ../.. &&
rm -rf kcov-master &&
for file in target/debug/laminar-*[^\.d]; do mkdir -p "target/cov/$(basename $file)"; ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file"; done &&
bash <(curl -s https://codecov.io/bash) &&
echo "Uploaded code coverage"
4 changes: 2 additions & 2 deletions README.md
@@ -1,6 +1,6 @@
# Laminar

[![Build Status][s2]][l2] [![Latest Version][s1]][l1] [![docs.rs][s4]][l4] [![Join us on Discord][s5]][l5] [![MIT/Apache][s3]][l3] ![Lines of Code][s6]
[![Build Status][s2]][l2] [![Latest Version][s1]][l1] [![docs.rs][s4]][l4] [![Join us on Discord][s5]][l5] [![MIT/Apache][s3]][l3] ![Lines of Code][s6] ![Coverage][s7]

[s1]: https://img.shields.io/crates/v/laminar.svg
[l1]: https://crates.io/crates/laminar
Expand All @@ -13,7 +13,7 @@
[s5]: https://img.shields.io/discord/425678876929163284.svg?logo=discord
[l5]: https://discord.gg/GnP5Whs
[s6]: https://tokei.rs/b1/github/amethyst/laminar?category=code

[s7]: https://codecov.io/gh/amethyst/laminar/branch/master/graphs/badge.svg

A UDP-based protocol that provides partial reliability. Coming soon!

Expand Down
13 changes: 7 additions & 6 deletions benches/packet_processing.rs
Expand Up @@ -2,13 +2,14 @@ extern crate laminar;
#[macro_use]
extern crate criterion;

use std::sync::Arc;

use self::laminar::net::{NetworkConfig, VirtualConnection};
use self::laminar::packet::header::{HeaderParser, HeaderReader, AckedPacketHeader, StandardHeader};
use self::laminar::packet::{Packet, PacketTypeId};
use self::laminar::packet::{PacketTypeId};
use laminar::infrastructure::DeliveryMethod;

use self::criterion::Criterion;
use std::net::SocketAddr;

const SERVER_ADDR: &str = "127.0.0.1:12345";
const CLIENT_ADDR: &str = "127.0.0.1:12346";
Expand All @@ -21,7 +22,7 @@ fn process_packet_before_send(connection: &mut VirtualConnection, config: &Netwo

fn send_unreliable_benchmark(c: &mut Criterion) {
let config = NetworkConfig::default();
let mut connection = VirtualConnection::new(SERVER_ADDR.parse().unwrap(), NetworkConfig::default());
let mut connection = VirtualConnection::new(SERVER_ADDR.parse().unwrap(), &Arc::new(NetworkConfig::default()));

c.bench_function("process unreliable before send", move |b| {
b.iter(|| process_packet_before_send(&mut connection, &config, DeliveryMethod::UnreliableUnordered))
Expand All @@ -30,7 +31,7 @@ fn send_unreliable_benchmark(c: &mut Criterion) {

fn send_reliable_benchmark(c: &mut Criterion) {
let config = NetworkConfig::default();
let mut connection = VirtualConnection::new(SERVER_ADDR.parse().unwrap(), NetworkConfig::default());
let mut connection = VirtualConnection::new(SERVER_ADDR.parse().unwrap(), &Arc::new(NetworkConfig::default()));

c.bench_function("process reliable before send", move |b| {
b.iter(|| process_packet_before_send(&mut connection, &config, DeliveryMethod::ReliableUnordered))
Expand All @@ -48,7 +49,7 @@ fn process_packet_when_received(
}

fn receive_unreliable_benchmark(c: &mut Criterion) {
let mut connection = VirtualConnection::new(SERVER_ADDR.parse().unwrap(), NetworkConfig::default());
let mut connection = VirtualConnection::new(SERVER_ADDR.parse().unwrap(), &Arc::new(NetworkConfig::default()));

// setup fake received bytes.
let packet_header = StandardHeader::new(DeliveryMethod::UnreliableUnordered, PacketTypeId::Packet);
Expand All @@ -63,7 +64,7 @@ fn receive_unreliable_benchmark(c: &mut Criterion) {
}

fn receive_reliable_benchmark(c: &mut Criterion) {
let mut connection = VirtualConnection::new(SERVER_ADDR.parse().unwrap(), NetworkConfig::default());
let mut connection = VirtualConnection::new(SERVER_ADDR.parse().unwrap(), &Arc::new(NetworkConfig::default()));

// setup fake received bytes.
let packet_header = AckedPacketHeader::new(StandardHeader::new(DeliveryMethod::ReliableUnordered, PacketTypeId::Packet),0, 1, 2);
Expand Down
1 change: 1 addition & 0 deletions codecov.yml
@@ -0,0 +1 @@
comment: off

0 comments on commit 46899b4

Please sign in to comment.