petabridge / NBench

Performance benchmarking and testing framework for .NET applications :chart_with_upwards_trend:
https://nbench.io/
Apache License 2.0
533 stars 46 forks source link

Linux: can't set processor affinity without being sudo in some environments #312

Closed Aaronontheweb closed 4 years ago

Aaronontheweb commented 4 years ago

Ran into this here: https://github.com/akkadotnet/HOCON/pull/236

Looks like

2020-02-24T21:44:58.2735223Z Starting Target: NBench (==> Build)
2020-02-24T21:44:58.2790788Z dotnet "run" "--no-build" "-c" "Release" " -- " "--output" "/home/vsts/work/1/s/PerfResults" "--concurrent" "true" "--trace" "true" "--diagnostic" 
2020-02-24T21:44:58.7141448Z DIAG: Executing with parameters [--trace true --concurrent true --output /home/vsts/work/1/s/PerfResults --diagnostic ]
2020-02-24T21:44:58.7148431Z DIAG: Unparsed arguments [/home/vsts/work/1/s/src/Hocon.Tests.Performance/bin/Release/netcoreapp2.1/Hocon.Tests.Performance.dll, -- ,--output,/home/vsts/work/1/s/PerfResults,--concurrent,true,--trace,true,--diagnostic]
2020-02-24T21:44:58.7215226Z DIAG: Captured, but unrecognized arguments: --output:[/home/vsts/work/1/s/PerfResults],--concurrent:[true],--trace:[true],--diagnostic:[]
2020-02-24T21:44:58.7308277Z 
2020-02-24T21:44:58.7472094Z Unhandled Exception: System.ComponentModel.Win32Exception: Permission denied
2020-02-24T21:44:58.7472917Z    at System.Diagnostics.Process.set_PriorityClassCore(ProcessPriorityClass value)
2020-02-24T21:44:58.7473593Z    at System.Diagnostics.Process.set_PriorityClass(ProcessPriorityClass value)
2020-02-24T21:44:58.7474197Z    at NBench.Sdk.TestRunner.SetProcessPriority(Boolean concurrent)
2020-02-24T21:44:58.7474646Z    at NBench.Sdk.TestRunner.Execute()
2020-02-24T21:44:58.7475093Z    at NBench.NBenchRunner.Run[TType]()
2020-02-24T21:44:58.7475749Z    at Hocon.Tests.Performance.Program.Main(String[] args) in /home/vsts/work/1/s/src/Hocon.Tests.Performance/Program.cs:line 9
2020-02-24T21:44:58.8733268Z Running build failed.
2020-02-24T21:44:58.8733871Z Error:
Aaronontheweb commented 4 years ago

Need to make this check:

https://github.com/petabridge/NBench/blob/d83b040ea5a28e0ece6a3b0350b7b0d82bba9a28/src/NBench/Sdk/TestRunner.cs#L84-L85

Work for Linux as a platform, not just Mono.