diff --git a/tests/benchmark/all.odin b/tests/benchmark/all.odin index d1b7662e2..357d86f67 100644 --- a/tests/benchmark/all.odin +++ b/tests/benchmark/all.odin @@ -2,3 +2,4 @@ package benchmarks @(require) import "crypto" @(require) import "hash" +@(require) import "simd/util" diff --git a/tests/benchmark/simd/util/benchmark_simd_util.odin b/tests/benchmark/simd/util/benchmark_simd_util.odin new file mode 100644 index 000000000..4538c6612 --- /dev/null +++ b/tests/benchmark/simd/util/benchmark_simd_util.odin @@ -0,0 +1,117 @@ +//+build i386, amd64 +package benchmark_simd_util + +import "core:fmt" +import "core:log" +import simd_util "core:simd/util" +import "core:testing" +import "core:time" + + +// These are the normal, unoptimized algorithms. + +plain_index_byte :: proc(s: []u8, c: byte) -> (res: int) #no_bounds_check { + for i := 0; i < len(s); i += 1 { + if s[i] == c { + return i + } + } + return -1 +} + +plain_last_index_byte :: proc(s: []u8, c: byte) -> (res: int) #no_bounds_check { + for i := len(s)-1; i >= 0; i -= 1 { + if s[i] == c { + return i + } + } + return -1 +} + +sizes := [?]int { + 15, 16, 17, + 31, 32, 33, + 256, + 512, + 1024, + 1024 * 1024, + 1024 * 1024 * 1024, +} + +run_trial_size :: proc(p: proc([]u8, byte) -> int, size: int, idx: int, warmup: int, runs: int) -> (timing: time.Duration) { + data := make([]u8, size) + defer delete(data) + + for i in 0..