Cleaned up phased_executor test
This commit is contained in:
@@ -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)
|
||||||
|
|
||||||
@@ -301,5 +293,4 @@ when ODIN_TEST {
|
|||||||
// and thread.pool_join completed without deadlock.
|
// and thread.pool_join completed without deadlock.
|
||||||
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")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user