This commit is contained in:
Kreyren 2020-02-09 15:29:08 +00:00
parent e31e90fa7b
commit 4416bb962f
3 changed files with 32 additions and 8 deletions

@ -16,4 +16,13 @@ clap = "2.33.0"
cargo-make = "0.27.0"
# Used for reading toml files
toml = "0.5.6"
zernit-logger = { path = "src/libs/rustlang/zernit-logger" }
# Custom logging solution
zernit-logger = { path = "src/libs/rustlang/zernit-logger" }
[dev-dependencies]
# Used for benchmarking
criterion = "0.3.1"
[[bench]]
name = "example_bench"
harness = false

@ -18,7 +18,7 @@ vendor:
@ [ ! -d vendor/rustlang ] && mkdir vendor/rustlang
@ [ ! -d vendor/rustlang/clap-rs ] && git clone https://github.com/clap-rs/clap.git vendor/rustlang/clap-rs
@ for file in vendor/rustlang/clap-rs/benches/*; do cp "$$file" benches/rustlang/claprs-$${file##vendor/rustlang/clap-rs/benches/??_}; done
build: build-rustlang build-clang-c build-gcc-c build-gcc-ccp build-clang-c build-clang-ccp build-brainfuck build-python build-vlang build-golang
build: build-rustlang build-clang-c build-gcc-c build-gcc-ccp build-clang-ccp build-brainfuck build-python build-vlang build-golang
# FIXME: Build in '$repodir/build/build-rustlang' instead of '$repodir/target' for multilang support
build-rustlang:
@ -49,10 +49,6 @@ build-gcc-ccp:
@ [ ! -f build/build-gcc ] && { gcc src/bin/main.c -o build/build-gcc/gcc-zernit || exit 1 ;}
@ printf '%s\n' "Compilation of target for gcc finished"
build-clang-c:
@ printf 'FIXME: %s\n' "translate zernit in clang"
@ exit 1
build-clang-ccp:
@ printf 'FIXME: %s\n' "translate zernit in clang"
@ exit 1
@ -128,10 +124,13 @@ bench-rustlang: vendor
## CLEAN ##
clean: clean-vendor
clean: clean-vendor clean-benches
@ [ -d build ] && rm -rf build
@ printf '%s\n' "Build directory has been cleaned"
clean-vendor:
@ # FIXME: Output helpful message if directory doesn't exists
@ [ -d vendor ] && rm -rf vendor
@ [ -d vendor ] && rm -rf vendor
clean-benches:
@ for file in benches/rustlang/claprs-*; do rm "$$file"; done

@ -0,0 +1,16 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
fn fibonacci(n: u64) -> u64 {
match n {
0 => 1,
1 => 1,
n => fibonacci(n-1) + fibonacci(n-2),
}
}
fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20))));
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);