Skip to content

Testing And Performance Analysis

ZjzMisaka edited this page Jul 18, 2026 · 34 revisions

Unit Testing

PowerThreadPool has been meticulously tested, achieving

  • 100% test coverage
    Codecov
    Codecov
  • Extensive use of Assert

to ensure robustness and reliability in various scenarios.

Benchmark

BenchmarkSyncWork


BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.32995) (Hyper-V)
Unknown processor
.NET SDK 10.0.302
  [Host]     : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  Job-VBUYPT : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

InvocationCount=1  UnrollFactor=1  

Method Mean Error StdDev Ratio Allocated Alloc Ratio
TestDotnetThreadPool 119.1 ms 0.60 ms 0.56 ms 1.00 32.13 KB 1.00
TestSmartThreadPool 122.5 ms 0.16 ms 0.13 ms 1.03 554.11 KB 17.24
TestPowerThreadPool 122.5 ms 0.26 ms 0.24 ms 1.03 660.41 KB 20.55

BenchmarkSyncShortWork

Run 1,000,000 tasks, each task performs 10 square root calculations


BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.32995) (Hyper-V)
Unknown processor
.NET SDK 10.0.302
  [Host]     : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  Job-VBUYPT : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

InvocationCount=1  UnrollFactor=1  

Method Mean Error StdDev Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
TestDotnetThreadPool 87.13 ms 0.971 ms 0.861 ms 1.00 0.01 1000.0000 - 30.52 MB 1.00
TestSmartThreadPool 1,245.49 ms 37.674 ms 111.082 ms 14.30 1.28 33000.0000 4000.0000 540.71 MB 17.72
TestPowerThreadPool 502.89 ms 9.850 ms 12.097 ms 5.77 0.15 33000.0000 - 534.03 MB 17.50
TestPowerThreadPoolSetEnablePoolIdleCheck 501.51 ms 9.791 ms 10.883 ms 5.76 0.13 33000.0000 - 534.65 MB 17.52

BenchmarkAsyncWork

Run 50 tasks, each task contains 3 await Task.Delay(10);


BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.32995) (Hyper-V)
Unknown processor
.NET SDK 10.0.302
  [Host]     : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  Job-VBUYPT : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

InvocationCount=1  UnrollFactor=1  

Method Mean Error StdDev Median Ratio RatioSD Allocated Alloc Ratio
TestTask 41.70 ms 2.067 ms 6.093 ms 41.50 ms 1.02 0.21 38.04 KB 1.00
TestPowerThreadPool 39.49 ms 2.200 ms 6.486 ms 36.86 ms 0.97 0.21 274.48 KB 7.22
TestPowerThreadPoolSync 550.92 ms 10.912 ms 26.354 ms 551.62 ms 13.49 2.06 68.07 KB 1.79

BenchmarkAsyncShortWork

Run 10,000 tasks, each task contains 10 await Task.Delay(0); or await Task.Yield();


BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.32995) (Hyper-V)
Unknown processor
.NET SDK 10.0.302
  [Host]     : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  Job-VBUYPT : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

InvocationCount=1  UnrollFactor=1  

Method Mean Error StdDev Median Ratio RatioSD Gen0 Gen1 Gen2 Allocated Alloc Ratio
TestTask 8.859 ms 0.1181 ms 0.3005 ms 8.835 ms 1.00 0.05 - - - 2.44 MB 1.00
TestTaskNoYield 1.761 ms 0.0218 ms 0.0193 ms 1.762 ms 0.20 0.01 - - - 1.45 MB 0.59
TestPowerThreadPool 387.989 ms 10.0154 ms 29.5305 ms 388.378 ms 43.84 3.60 8000.0000 7000.0000 2000.0000 110.26 MB 45.15
TestPowerThreadPoolNoYield 24.007 ms 2.1103 ms 5.9174 ms 21.869 ms 2.71 0.67 1000.0000 - - 28.91 MB 11.84
TestPowerThreadPoolSync 13.487 ms 0.2240 ms 0.1748 ms 13.538 ms 1.52 0.05 - - - 5.84 MB 2.39

BenchmarkTotalExecutionTimeOfAllPriorityWork

First enqueue 50 low priority tasks, then use a loop to enqueue 200 low, medium, and high priority tasks, and compute the total completion time of these 600 tasks.


BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.32995) (Hyper-V)
Unknown processor
.NET SDK 10.0.302
  [Host]     : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  Job-VBUYPT : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

InvocationCount=1  UnrollFactor=1  

Method Mean Error StdDev Ratio Allocated Alloc Ratio
TestPriorityNotPropagatedThreadStaticSeed 980.9 ms 0.42 ms 0.35 ms 1.00 1.7 MB 0.52
TestPriorityPropagatedViaPerPriorityLane 981.4 ms 0.95 ms 0.84 ms 1.00 1.77 MB 0.54
TestPriorityPropagatedViaSyncContext 980.9 ms 0.57 ms 0.48 ms 1.00 1.5 MB 0.46
TestPowerThreadPool 982.9 ms 1.55 ms 1.37 ms 1.00 3.28 MB 1.00

BenchmarkTotalExecutionTimeOfHighPriorityWork

First enqueue 50 low priority tasks, then use a loop to enqueue 200 low, medium, and high priority tasks, and compute the total completion time of the 200 high priority tasks.


BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.32995) (Hyper-V)
Unknown processor
.NET SDK 10.0.302
  [Host]     : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  Job-VBUYPT : .NET 8.0.28 (8.0.2826.26413), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

InvocationCount=1  UnrollFactor=1  

Method Mean Error StdDev Ratio RatioSD Allocated Alloc Ratio
TestPriorityNotPropagatedThreadStaticSeed 969.3 ms 18.64 ms 26.13 ms 2.94 0.08 1.68 MB 0.88
TestPriorityPropagatedViaPerPriorityLane 672.2 ms 51.09 ms 150.65 ms 2.04 0.45 1.32 MB 0.69
TestPriorityPropagatedViaSyncContext 722.5 ms 44.80 ms 132.10 ms 2.19 0.40 1.72 MB 0.90
TestPowerThreadPool 330.2 ms 1.24 ms 1.04 ms 1.00 0.00 1.91 MB 1.00

Clone this wiki locally