Browse Source

fix benchmarks not compiling and make sure it doesn't happen again by checking

Laytan Laats 10 months ago
parent
commit
55e9a1b971
2 changed files with 14 additions and 4 deletions
  1. 10 0
      .github/workflows/ci.yml
  2. 4 4
      tests/benchmark/bytes/benchmark_bytes.odin

+ 10 - 0
.github/workflows/ci.yml

@@ -36,6 +36,8 @@ jobs:
           ./odin test tests/core/speed.odin -file -all-packages -vet -strict-style -disallow-do -o:speed -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
           ./odin test tests/vendor -all-packages -vet -strict-style -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
           (cd tests/issues; ./run.sh)
+          ./odin check tests/benchmarks -vet -strict-style -no-entry-point
+
   build_freebsd:
     name: FreeBSD Build, Check, and Test
     runs-on: ubuntu-latest
@@ -64,6 +66,7 @@ jobs:
           ./odin test tests/core/speed.odin -file -all-packages -vet -strict-style -disallow-do -o:speed -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
           ./odin test tests/vendor -all-packages -vet -strict-style -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
           (cd tests/issues; ./run.sh)
+          ./odin check tests/benchmarks -vet -strict-style -no-entry-point
   ci:
     strategy:
       fail-fast: false
@@ -128,6 +131,8 @@ jobs:
           cd tests/issues
           ./run.sh
 
+      - name: Check benchmarks
+        run: ./odin check tests/benchmarks -vet -strict-style -no-entry-point
       - name: Odin check examples/all for Linux i386
         run: ./odin check examples/all -vet -strict-style -disallow-do -target:linux_i386
         if: matrix.os == 'ubuntu-latest'
@@ -203,6 +208,11 @@ jobs:
         run: |
           call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
           odin test tests/internal -all-packages -vet -strict-style -disallow-do -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
+      - name: Check benchmarks
+        shell: cmd
+        run: |
+          call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
+          odin check tests/benchmarks -vet -strict-style -no-entry-point
       - name: Odin documentation tests
         shell: cmd
         run: |

+ 4 - 4
tests/benchmark/bytes/benchmark_bytes.odin

@@ -25,7 +25,7 @@ sizes := [?]int {
 
 // These are the normal, unoptimized algorithms.
 
-plain_index_byte :: proc(s: []u8, c: byte) -> (res: int) #no_bounds_check {
+plain_index_byte :: proc "contextless" (s: []u8, c: byte) -> (res: int) #no_bounds_check {
 	for i := 0; i < len(s); i += 1 {
 		if s[i] == c {
 			return i
@@ -34,7 +34,7 @@ plain_index_byte :: proc(s: []u8, c: byte) -> (res: int) #no_bounds_check {
 	return -1
 }
 
-plain_last_index_byte :: proc(s: []u8, c: byte) -> (res: int) #no_bounds_check {
+plain_last_index_byte :: proc "contextless" (s: []u8, c: byte) -> (res: int) #no_bounds_check {
 	for i := len(s)-1; i >= 0; i -= 1 {
 		if s[i] == c {
 			return i
@@ -43,7 +43,7 @@ plain_last_index_byte :: proc(s: []u8, c: byte) -> (res: int) #no_bounds_check {
 	return -1
 }
 
-run_trial_size :: proc(p: proc([]u8, byte) -> int, size: int, idx: int, runs: int) -> (timing: time.Duration) {
+run_trial_size :: proc(p: proc "contextless" ([]u8, byte) -> int, size: int, idx: int, runs: int) -> (timing: time.Duration) {
 	data := make([]u8, size)
 	defer delete(data)
 
@@ -67,7 +67,7 @@ run_trial_size :: proc(p: proc([]u8, byte) -> int, size: int, idx: int, runs: in
 	return
 }
 
-bench_table :: proc(algo_name: string, forward: bool, plain: proc([]u8, byte) -> int, simd: proc([]u8, byte) -> int) {
+bench_table :: proc(algo_name: string, forward: bool, plain: proc "contextless" ([]u8, byte) -> int, simd: proc "contextless" ([]u8, byte) -> int) {
 	string_buffer := strings.builder_make()
 	defer strings.builder_destroy(&string_buffer)