2016-07-17 11:11:33 +08:00
|
|
|
// This file is part of libfringe, a low-level green threading library.
|
|
|
|
// Copyright (c) whitequark <whitequark@whitequark.org>
|
|
|
|
// See the LICENSE file included in this distribution.
|
|
|
|
#![feature(test)]
|
|
|
|
extern crate test;
|
|
|
|
extern crate fringe;
|
|
|
|
|
|
|
|
use fringe::{OsStack, Generator};
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn generate(b: &mut test::Bencher) {
|
|
|
|
let stack = OsStack::new(0).unwrap();
|
2016-08-12 05:04:40 +08:00
|
|
|
let mut identity = Generator::new(stack, move |yielder, mut input| {
|
|
|
|
loop { input = yielder.generate(input) }
|
2016-07-17 11:11:33 +08:00
|
|
|
});
|
|
|
|
|
2016-08-12 05:04:40 +08:00
|
|
|
b.iter(|| test::black_box(identity.resume(test::black_box(0))));
|
2016-07-17 11:11:33 +08:00
|
|
|
}
|