Reputation: 984
I am using DotNet Benchmark and I can get the memory usage information as in the table below. But I need to access how much CPU usage is in the process I have done. Does DotNetBenchmark have this feature? If not, what method should I use?
Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|
Get10000Records | 38.70 ms | 1.413 ms | 4.165 ms | 2000.0000 | 1000.0000 | - | 12 MB |
Get100000Records | 558.30 ms | 11.157 ms | 22.024 ms | 19000.0000 | 6000.0000 | 2000.0000 | 121 MB |
Upvotes: 4
Views: 1979
Reputation: 29548
I wanted this as well and ended up implementing my own CpuDiagnoser
to do so.
Here is the gist. It requires that your benchmarks are run in-process, and I suspect the timings aren't reliable enough unless your benchmarks run for at least tens of milliseconds.
Copy this file into your benchmark project, add [CpuDiagnoser]
to a benchmark class and it will output CPU usage for user and priviledged time. The tests need to be run InProc for this to work - this is done by adding the [InProcess] attribute on the benchmark class.
Upvotes: 0