mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
@@ -35,7 +35,6 @@ jobs:
|
|||||||
./odin test tests/core/normal.odin -file -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
./odin test tests/core/normal.odin -file -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
||||||
./odin test tests/core/speed.odin -file -all-packages -o:speed -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
./odin test tests/core/speed.odin -file -all-packages -o:speed -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
||||||
./odin test tests/vendor -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
./odin test tests/vendor -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
||||||
./odin test tests/benchmark -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
|
||||||
(cd tests/issues; ./run.sh)
|
(cd tests/issues; ./run.sh)
|
||||||
build_freebsd:
|
build_freebsd:
|
||||||
name: FreeBSD Build, Check, and Test
|
name: FreeBSD Build, Check, and Test
|
||||||
@@ -64,7 +63,6 @@ jobs:
|
|||||||
./odin test tests/core/normal.odin -file -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
./odin test tests/core/normal.odin -file -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
||||||
./odin test tests/core/speed.odin -file -all-packages -o:speed -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
./odin test tests/core/speed.odin -file -all-packages -o:speed -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
||||||
./odin test tests/vendor -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
./odin test tests/vendor -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
||||||
./odin test tests/benchmark -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
|
||||||
(cd tests/issues; ./run.sh)
|
(cd tests/issues; ./run.sh)
|
||||||
ci:
|
ci:
|
||||||
strategy:
|
strategy:
|
||||||
@@ -125,8 +123,6 @@ jobs:
|
|||||||
run: ./odin test tests/vendor -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
run: ./odin test tests/vendor -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
||||||
- name: Internals tests
|
- name: Internals tests
|
||||||
run: ./odin test tests/internal -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
run: ./odin test tests/internal -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
||||||
- name: Core library benchmarks
|
|
||||||
run: ./odin test tests/benchmark -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
|
||||||
- name: GitHub Issue tests
|
- name: GitHub Issue tests
|
||||||
run: |
|
run: |
|
||||||
cd tests/issues
|
cd tests/issues
|
||||||
@@ -196,11 +192,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
|
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
|
||||||
odin test tests/core/speed.odin -o:speed -file -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
odin test tests/core/speed.odin -o:speed -file -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
||||||
- name: Core library benchmarks
|
|
||||||
shell: cmd
|
|
||||||
run: |
|
|
||||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat
|
|
||||||
odin test tests/benchmark -all-packages -define:ODIN_TEST_FANCY=false -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true
|
|
||||||
- name: Vendor library tests
|
- name: Vendor library tests
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -4,8 +4,21 @@ import "core:bytes"
|
|||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import "core:log"
|
import "core:log"
|
||||||
import "core:testing"
|
import "core:testing"
|
||||||
|
import "core:strings"
|
||||||
|
import "core:text/table"
|
||||||
import "core:time"
|
import "core:time"
|
||||||
|
|
||||||
|
RUNS_PER_SIZE :: 2500
|
||||||
|
|
||||||
|
sizes := [?]int {
|
||||||
|
15, 16, 17,
|
||||||
|
31, 32, 33,
|
||||||
|
256,
|
||||||
|
512,
|
||||||
|
1024,
|
||||||
|
1024 * 1024,
|
||||||
|
// 1024 * 1024 * 1024,
|
||||||
|
}
|
||||||
|
|
||||||
// These are the normal, unoptimized algorithms.
|
// These are the normal, unoptimized algorithms.
|
||||||
|
|
||||||
@@ -27,17 +40,7 @@ plain_last_index_byte :: proc(s: []u8, c: byte) -> (res: int) #no_bounds_check {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
sizes := [?]int {
|
run_trial_size :: proc(p: proc([]u8, byte) -> int, size: int, idx: int, runs: int) -> (timing: time.Duration) {
|
||||||
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)
|
data := make([]u8, size)
|
||||||
defer delete(data)
|
defer delete(data)
|
||||||
|
|
||||||
@@ -48,10 +51,6 @@ run_trial_size :: proc(p: proc([]u8, byte) -> int, size: int, idx: int, warmup:
|
|||||||
|
|
||||||
accumulator: int
|
accumulator: int
|
||||||
|
|
||||||
for _ in 0..<warmup {
|
|
||||||
accumulator += p(data, 'z')
|
|
||||||
}
|
|
||||||
|
|
||||||
for _ in 0..<runs {
|
for _ in 0..<runs {
|
||||||
start := time.now()
|
start := time.now()
|
||||||
accumulator += p(data, 'z')
|
accumulator += p(data, 'z')
|
||||||
@@ -65,44 +64,51 @@ run_trial_size :: proc(p: proc([]u8, byte) -> int, size: int, idx: int, warmup:
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
HOT :: 3
|
bench_table :: proc(algo_name: string, forward: bool, plain: proc([]u8, byte) -> int, simd: proc([]u8, byte) -> int) {
|
||||||
|
string_buffer := strings.builder_make()
|
||||||
|
defer strings.builder_destroy(&string_buffer)
|
||||||
|
|
||||||
|
tbl: table.Table
|
||||||
|
table.init(&tbl)
|
||||||
|
defer table.destroy(&tbl)
|
||||||
|
|
||||||
|
// table.caption(&tbl, "index_byte benchmark")
|
||||||
|
table.aligned_header_of_values(&tbl, .Right, "Algorithm", "Size", "Iterations", "Scalar", "SIMD", "SIMD Relative (%)", "SIMD Relative (x)")
|
||||||
|
|
||||||
@test
|
|
||||||
benchmark_plain_index_cold :: proc(t: ^testing.T) {
|
|
||||||
report: string
|
|
||||||
for size in sizes {
|
for size in sizes {
|
||||||
timing := run_trial_size(plain_index_byte, size, size - 1, 0, 1)
|
needle_index := size - 1 if forward else 0
|
||||||
report = fmt.tprintf("%s\n +++ % 8M | %v", report, size, timing)
|
|
||||||
timing = run_trial_size(plain_last_index_byte, size, 0, 0, 1)
|
plain_timing := run_trial_size(plain, size, needle_index, RUNS_PER_SIZE)
|
||||||
report = fmt.tprintf("%s\n (last) +++ % 8M | %v", report, size, timing)
|
simd_timing := run_trial_size(simd, size, needle_index, RUNS_PER_SIZE)
|
||||||
|
|
||||||
|
_plain := fmt.tprintf("%8M", plain_timing)
|
||||||
|
_simd := fmt.tprintf("%8M", simd_timing)
|
||||||
|
_relp := fmt.tprintf("%.3f %%", f64(simd_timing) / f64(plain_timing) * 100.0)
|
||||||
|
_relx := fmt.tprintf("%.3f x", 1 / (f64(simd_timing) / f64(plain_timing)))
|
||||||
|
|
||||||
|
table.aligned_row_of_values(
|
||||||
|
&tbl,
|
||||||
|
.Right,
|
||||||
|
algo_name,
|
||||||
|
size, RUNS_PER_SIZE, _plain, _simd, _relp, _relx)
|
||||||
}
|
}
|
||||||
log.info(report)
|
|
||||||
|
builder_writer := strings.to_writer(&string_buffer)
|
||||||
|
|
||||||
|
fmt.sbprintln(&string_buffer)
|
||||||
|
table.write_plain_table(builder_writer, &tbl)
|
||||||
|
|
||||||
|
my_table_string := strings.to_string(string_buffer)
|
||||||
|
log.info(my_table_string)
|
||||||
}
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
benchmark_plain_index_hot :: proc(t: ^testing.T) {
|
benchmark_index_byte :: proc(t: ^testing.T) {
|
||||||
report: string
|
bench_table("index_byte", true, plain_index_byte, bytes.index_byte)
|
||||||
for size in sizes {
|
// bench_table("last_index_byte", false, plain_last_index_byte, bytes.last_index_byte)
|
||||||
timing := run_trial_size(plain_index_byte, size, size - 1, HOT, HOT)
|
|
||||||
report = fmt.tprintf("%s\n +++ % 8M | %v", report, size, timing)
|
|
||||||
timing = run_trial_size(plain_last_index_byte, size, 0, HOT, HOT)
|
|
||||||
report = fmt.tprintf("%s\n (last) +++ % 8M | %v", report, size, timing)
|
|
||||||
}
|
|
||||||
log.info(report)
|
|
||||||
}
|
|
||||||
|
|
||||||
@test
|
|
||||||
benchmark_simd_index_cold :: proc(t: ^testing.T) {
|
|
||||||
report: string
|
|
||||||
for size in sizes {
|
|
||||||
timing := run_trial_size(bytes.index_byte, size, size - 1, 0, 1)
|
|
||||||
report = fmt.tprintf("%s\n +++ % 8M | %v", report, size, timing)
|
|
||||||
timing = run_trial_size(bytes.last_index_byte, size, 0, 0, 1)
|
|
||||||
report = fmt.tprintf("%s\n (last) +++ % 8M | %v", report, size, timing)
|
|
||||||
}
|
|
||||||
log.info(report)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@test
|
@test
|
||||||
benchmark_simd_index_hot :: proc(t: ^testing.T) {
|
benchmark_simd_index_hot :: proc(t: ^testing.T) {
|
||||||
report: string
|
report: string
|
||||||
@@ -114,3 +120,4 @@ benchmark_simd_index_hot :: proc(t: ^testing.T) {
|
|||||||
}
|
}
|
||||||
log.info(report)
|
log.info(report)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@@ -392,7 +392,7 @@ _benchmark_aes256_gcm :: proc(
|
|||||||
iv: [aes.GCM_IV_SIZE]byte
|
iv: [aes.GCM_IV_SIZE]byte
|
||||||
tag: [aes.GCM_TAG_SIZE]byte = ---
|
tag: [aes.GCM_TAG_SIZE]byte = ---
|
||||||
|
|
||||||
ctx := transmute(^aes.Context_GCM)context.user_ptr
|
ctx := (^aes.Context_GCM)(context.user_ptr)
|
||||||
|
|
||||||
for _ in 0 ..= options.rounds {
|
for _ in 0 ..= options.rounds {
|
||||||
aes.seal_gcm(ctx, buf, tag[:], iv[:], nil, buf)
|
aes.seal_gcm(ctx, buf, tag[:], iv[:], nil, buf)
|
||||||
|
|||||||
Reference in New Issue
Block a user