mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2025-06-11 02:43:20 +02:00
Kick out asyncio into an external crate for later
This commit is contained in:
@ -1,25 +1,22 @@
|
||||
#![feature(test)]
|
||||
use executor::prelude::*;
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
||||
extern crate test;
|
||||
|
||||
use bastion_executor::prelude::*;
|
||||
use lightproc::proc_stack::ProcStack;
|
||||
use test::{black_box, Bencher};
|
||||
|
||||
#[bench]
|
||||
fn increment(b: &mut Bencher) {
|
||||
fn increment(b: &mut Criterion) {
|
||||
let mut sum = 0;
|
||||
let executor = Executor::new();
|
||||
|
||||
b.iter(|| {
|
||||
run(
|
||||
b.bench_function("Executor::run", |b| b.iter(|| {
|
||||
executor.run(
|
||||
async {
|
||||
(0..10_000_000).for_each(|_| {
|
||||
sum += 1;
|
||||
});
|
||||
},
|
||||
ProcStack::default(),
|
||||
);
|
||||
});
|
||||
}));
|
||||
|
||||
black_box(sum);
|
||||
}
|
||||
|
||||
criterion_group!(perf, increment);
|
||||
criterion_main!(perf);
|
@ -1,23 +1,16 @@
|
||||
#![feature(test)]
|
||||
|
||||
extern crate test;
|
||||
|
||||
use bastion_executor::load_balancer;
|
||||
use bastion_executor::prelude::spawn;
|
||||
use executor::load_balancer;
|
||||
use executor::prelude::*;
|
||||
use futures_timer::Delay;
|
||||
use lightproc::proc_stack::ProcStack;
|
||||
use std::time::Duration;
|
||||
use test::Bencher;
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
||||
#[cfg(feature = "tokio-runtime")]
|
||||
mod tokio_benchs {
|
||||
mod benches {
|
||||
use super::*;
|
||||
#[bench]
|
||||
fn spawn_lot(b: &mut Bencher) {
|
||||
pub fn spawn_lot(b: &mut Bencher) {
|
||||
tokio_test::block_on(async { _spawn_lot(b) });
|
||||
}
|
||||
#[bench]
|
||||
fn spawn_single(b: &mut Bencher) {
|
||||
pub fn spawn_single(b: &mut Bencher) {
|
||||
tokio_test::block_on(async {
|
||||
_spawn_single(b);
|
||||
});
|
||||
@ -25,46 +18,47 @@ mod tokio_benchs {
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "tokio-runtime"))]
|
||||
mod no_tokio_benchs {
|
||||
mod benches {
|
||||
use super::*;
|
||||
#[bench]
|
||||
fn spawn_lot(b: &mut Bencher) {
|
||||
|
||||
pub fn spawn_lot(b: &mut Criterion) {
|
||||
_spawn_lot(b);
|
||||
}
|
||||
#[bench]
|
||||
fn spawn_single(b: &mut Bencher) {
|
||||
pub fn spawn_single(b: &mut Criterion) {
|
||||
_spawn_single(b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
criterion_group!(spawn, benches::spawn_lot, benches::spawn_single);
|
||||
criterion_main!(spawn);
|
||||
|
||||
// Benchmark for a 10K burst task spawn
|
||||
fn _spawn_lot(b: &mut Bencher) {
|
||||
let proc_stack = ProcStack::default();
|
||||
b.iter(|| {
|
||||
fn _spawn_lot(b: &mut Criterion) {
|
||||
let executor = Executor::new();
|
||||
b.bench_function("spawn_lot", |b| b.iter(|| {
|
||||
let _ = (0..10_000)
|
||||
.map(|_| {
|
||||
spawn(
|
||||
executor.spawn(
|
||||
async {
|
||||
let duration = Duration::from_millis(1);
|
||||
Delay::new(duration).await;
|
||||
},
|
||||
proc_stack.clone(),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
// Benchmark for a single task spawn
|
||||
fn _spawn_single(b: &mut Bencher) {
|
||||
let proc_stack = ProcStack::default();
|
||||
b.iter(|| {
|
||||
spawn(
|
||||
fn _spawn_single(b: &mut Criterion) {
|
||||
let executor = Executor::new();
|
||||
b.bench_function("spawn single", |b| b.iter(|| {
|
||||
executor.spawn(
|
||||
async {
|
||||
let duration = Duration::from_millis(1);
|
||||
Delay::new(duration).await;
|
||||
},
|
||||
proc_stack.clone(),
|
||||
);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
#![feature(test)]
|
||||
|
||||
extern crate test;
|
||||
use bastion_executor::load_balancer::{core_count, get_cores, stats, SmpStats};
|
||||
use bastion_executor::placement;
|
||||
use executor::load_balancer::{core_count, get_cores, stats, SmpStats};
|
||||
use executor::placement;
|
||||
use std::thread;
|
||||
use test::Bencher;
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
||||
fn stress_stats<S: SmpStats + Sync + Send>(stats: &'static S) {
|
||||
let mut handles = Vec::with_capacity(*core_count());
|
||||
@ -29,15 +26,13 @@ fn stress_stats<S: SmpStats + Sync + Send>(stats: &'static S) {
|
||||
// previous lock based stats benchmark 1,352,791 ns/iter (+/- 2,682,013)
|
||||
|
||||
// 158,278 ns/iter (+/- 117,103)
|
||||
#[bench]
|
||||
fn lockless_stats_bench(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
fn lockless_stats_bench(b: &mut Criterion) {
|
||||
b.bench_function("stress_stats", |b| b.iter(|| {
|
||||
stress_stats(stats());
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lockless_stats_bad_load(b: &mut Bencher) {
|
||||
fn lockless_stats_bad_load(b: &mut Criterion) {
|
||||
let stats = stats();
|
||||
const MAX_CORE: usize = 256;
|
||||
for i in 0..MAX_CORE {
|
||||
@ -50,13 +45,12 @@ fn lockless_stats_bad_load(b: &mut Bencher) {
|
||||
}
|
||||
}
|
||||
|
||||
b.iter(|| {
|
||||
b.bench_function("get_sorted_load", |b| b.iter(|| {
|
||||
let _sorted_load = stats.get_sorted_load();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lockless_stats_good_load(b: &mut Bencher) {
|
||||
fn lockless_stats_good_load(b: &mut Criterion) {
|
||||
let stats = stats();
|
||||
const MAX_CORE: usize = 256;
|
||||
for i in 0..MAX_CORE {
|
||||
@ -65,7 +59,11 @@ fn lockless_stats_good_load(b: &mut Bencher) {
|
||||
stats.store_load(i, i);
|
||||
}
|
||||
|
||||
b.iter(|| {
|
||||
b.bench_function("get_sorted_load", |b| b.iter(|| {
|
||||
let _sorted_load = stats.get_sorted_load();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
criterion_group!(stats_bench, lockless_stats_bench, lockless_stats_bad_load,
|
||||
lockless_stats_good_load);
|
||||
criterion_main!(stats_bench);
|
||||
|
Reference in New Issue
Block a user