phased-executor #4

Merged
zack merged 5 commits from phased-executor into master 2026-04-03 01:53:24 +00:00
Showing only changes of commit fd3cd1b6e6 - Show all commits

View File

@@ -243,35 +243,27 @@ exec_join :: proc(executor: ^Executor($T)) {
import "core:fmt" import "core:fmt"
import "core:testing" import "core:testing"
when ODIN_TEST { @(test)
@(private = "file") stress_test_executor :: proc(t: ^testing.T) {
STRESS_TOTAL_CMDS :: 200_000 STRESS_TOTAL_CMDS :: 200_000
@(private = "file")
STRESS_NUM_THREADS :: 8 STRESS_NUM_THREADS :: 8
@(private = "file")
STRESS_NUM_ROUNDS :: 100 STRESS_NUM_ROUNDS :: 100
@(private = "file")
STRESS_CMDS_PER_ROUND :: STRESS_TOTAL_CMDS / STRESS_NUM_ROUNDS STRESS_CMDS_PER_ROUND :: STRESS_TOTAL_CMDS / STRESS_NUM_ROUNDS
@(private = "file")
Stress_Cmd :: union { Stress_Cmd :: union {
Stress_Payload, Stress_Payload,
} }
@(private = "file")
Stress_Payload :: struct { Stress_Payload :: struct {
exec_counts: ^[STRESS_TOTAL_CMDS]uint, exec_counts: ^[STRESS_TOTAL_CMDS]uint,
id: int, id: int,
} }
@(private = "file")
stress_handler :: proc(command: Stress_Cmd) { stress_handler :: proc(command: Stress_Cmd) {
payload := command.(Stress_Payload) payload := command.(Stress_Payload)
intrinsics.atomic_add_explicit(&payload.exec_counts[payload.id], 1, .Release) intrinsics.atomic_add_explicit(&payload.exec_counts[payload.id], 1, .Release)
} }
@(test)
stress_test_executor :: proc(t: ^testing.T) {
exec_counts := new([STRESS_TOTAL_CMDS]uint) exec_counts := new([STRESS_TOTAL_CMDS]uint)
defer free(exec_counts) defer free(exec_counts)
@@ -302,4 +294,3 @@ when ODIN_TEST {
destroy_executor(&executor) destroy_executor(&executor)
testing.expect(t, !executor.initialized, "Executor still marked initialized after destroy") testing.expect(t, !executor.initialized, "Executor still marked initialized after destroy")
} }
}