Added toy in Rust

This commit is contained in:
sternj 2022-08-12 19:48:45 -04:00
parent a7a29361fb
commit ecf5b50b0d
3 changed files with 62 additions and 0 deletions

32
benchmarks/toy-rs/Cargo.lock generated Normal file
View File

@ -0,0 +1,32 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "coz"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cef55b3fe2f5477d59e12bc792e8b3c95a25bd099eadcfae006ecea136de76e2"
dependencies = [
"libc",
"once_cell",
]
[[package]]
name = "libc"
version = "0.2.131"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04c3b4822ccebfa39c02fc03d1534441b22ead323fa0f48bb7ddd8e6ba076a40"
[[package]]
name = "once_cell"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
[[package]]
name = "toy-rs"
version = "0.1.0"
dependencies = [
"coz",
]

View File

@ -0,0 +1,9 @@
[package]
name = "toy-rs"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
coz = "0.1"

View File

@ -0,0 +1,21 @@
#[allow(unused)]
use coz;
use std::thread;
#[no_mangle]
pub fn a_first_fn() {
for _x in 0..2000000000 {}
}
#[no_mangle]
pub fn b_second_fn() {
for _y in 0..1900000000 {}
}
fn main() {
let handle1 = thread::spawn(|| a_first_fn());
let handle2 = thread::spawn(|| b_second_fn());
handle1.join().unwrap();
handle2.join().unwrap();
coz::progress!();
}