libfringe/benches/kernel_swap.rs
edef b986931817 remove copyright years
They're obnoxious to update, and I'm told they have no legal value.
2016-03-22 08:25:23 +01:00

34 lines
691 B
Rust

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