Add C malloc benchmark.
Change-Id: I56727f847d157d797369c50dbde9cd33a4050016
diff --git a/benches/benchmarks.rs b/benches/benchmarks.rs
index 5d5b958..ec5e75c 100644
--- a/benches/benchmarks.rs
+++ b/benches/benchmarks.rs
@@ -5,7 +5,9 @@
extern crate num;
extern crate test;
-use rust_samples::swapper::{CAllocaSwapper, CLoopSwapper, LoopSwapper, PtrSwapper, Swapper};
+use rust_samples::swapper::{
+ CAllocaSwapper, CLoopSwapper, CMallocSwapper, LoopSwapper, PtrSwapper, Swapper,
+};
use heapless::consts::{U10, U100, U1000, U10000, U100000, U1000000};
use num::{one, zero, Num};
@@ -179,3 +181,33 @@
fn bench_cswap_alloca_len_1000000(b: &mut Bencher) {
bench_swap::<CAllocaSwapper, BenchInt, U1000000>(b);
}
+
+#[bench]
+fn bench_cswap_malloc_len_10(b: &mut Bencher) {
+ bench_swap::<CMallocSwapper, BenchInt, U10>(b);
+}
+
+#[bench]
+fn bench_cswap_malloc_len_100(b: &mut Bencher) {
+ bench_swap::<CMallocSwapper, BenchInt, U100>(b);
+}
+
+#[bench]
+fn bench_cswap_malloc_len_1000(b: &mut Bencher) {
+ bench_swap::<CMallocSwapper, BenchInt, U1000>(b);
+}
+
+#[bench]
+fn bench_cswap_malloc_len_10000(b: &mut Bencher) {
+ bench_swap::<CMallocSwapper, BenchInt, U10000>(b);
+}
+
+#[bench]
+fn bench_cswap_malloc_len_100000(b: &mut Bencher) {
+ bench_swap::<CMallocSwapper, BenchInt, U100000>(b);
+}
+
+#[bench]
+fn bench_cswap_malloc_len_1000000(b: &mut Bencher) {
+ bench_swap::<CMallocSwapper, BenchInt, U1000000>(b);
+}