phased-executor #4
@@ -243,35 +243,27 @@ exec_join :: proc(executor: ^Executor($T)) {
|
||||
import "core:fmt"
|
||||
import "core:testing"
|
||||
|
||||
when ODIN_TEST {
|
||||
@(private = "file")
|
||||
@(test)
|
||||
stress_test_executor :: proc(t: ^testing.T) {
|
||||
STRESS_TOTAL_CMDS :: 200_000
|
||||
@(private = "file")
|
||||
STRESS_NUM_THREADS :: 8
|
||||
@(private = "file")
|
||||
STRESS_NUM_ROUNDS :: 100
|
||||
@(private = "file")
|
||||
STRESS_CMDS_PER_ROUND :: STRESS_TOTAL_CMDS / STRESS_NUM_ROUNDS
|
||||
|
||||
@(private = "file")
|
||||
Stress_Cmd :: union {
|
||||
Stress_Payload,
|
||||
}
|
||||
|
||||
@(private = "file")
|
||||
Stress_Payload :: struct {
|
||||
exec_counts: ^[STRESS_TOTAL_CMDS]uint,
|
||||
id: int,
|
||||
}
|
||||
|
||||
@(private = "file")
|
||||
stress_handler :: proc(command: Stress_Cmd) {
|
||||
payload := command.(Stress_Payload)
|
||||
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)
|
||||
defer free(exec_counts)
|
||||
|
||||
@@ -301,5 +293,4 @@ when ODIN_TEST {
|
||||
// and thread.pool_join completed without deadlock.
|
||||
destroy_executor(&executor)
|
||||
testing.expect(t, !executor.initialized, "Executor still marked initialized after destroy")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user