libfringe/benches/kernel_swap.rs

34 lines
697 B
Rust
Raw Normal View History

2015-04-16 20:06:57 +08:00
// This file is part of libfringe, a low-level green threading library.
2015-04-16 18:08:44 +08:00
// Copyright (c) 2015, edef <edef@edef.eu>
// See the LICENSE file included in this distribution.
#![cfg(target_os = "linux")]
2015-02-03 03:17:23 +08:00
#![feature(asm, test)]
2015-01-14 14:01:43 +08:00
extern crate test;
use test::Bencher;
2015-04-17 00:50:15 +08:00
#[cfg(target_arch = "x86_64")]
2015-01-14 14:01:43 +08:00
#[bench]
fn kernel_swap(b: &mut Bencher) {
b.iter(|| unsafe {
asm!("movq $$102, %rax\n\
syscall"
:
:
: "rax", "rcx"
: "volatile");
});
}
2015-04-17 00:50:15 +08:00
#[cfg(target_arch = "x86")]
#[bench]
fn kernel_swap(b: &mut Bencher) {
b.iter(|| unsafe {
asm!("mov $$24, %eax\n\
int $$0x80"
:
:
: "eax"
: "volatile");
});
}