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>
|
2016-08-21 05:45:01 +08:00
|
|
|
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
|
|
|
|
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
|
|
|
|
// http://opensource.org/licenses/MIT>, at your option. This file may not be
|
|
|
|
// copied, modified, or distributed except according to those terms.
|
2016-07-17 11:11:33 +08:00
|
|
|
#![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| {
|
2016-08-30 18:37:15 +08:00
|
|
|
loop { input = yielder.suspend(input) }
|
2016-07-17 11:11:33 +08:00
|
|
|
});
|
|
|
|
|
2016-09-07 20:56:32 +08:00
|
|
|
b.iter(|| for _ in 0..10 { test::black_box(identity.resume(test::black_box(0))); });
|
2016-07-17 11:11:33 +08:00
|
|
|
}
|