Question: How do you solve the error in BenchmarkDotNet that says "RPlotExporter couldn't find Rscript.exe in your PATH and no #R_HOME environment variable is defined"?
Login to See the Rest of the Answer
Answer: You need to create an environment variable called "R_HOME" and make it point to "C:\Program Files\R-4.2.1" and then #reboot your computer.
If you see an error that says "RPlotExporter requires R_HOME to point to the parent directory of the existing '\bin\Rscript.exe (currently points to C:\Program Files\R\R-4.2.1\bin)" then remove the "\bin" from the Value of the "R_HOME" environment variable.
After changing the Path you need to shut down your computer, let it sit for a minute then start it again. This makes the computer load the Modified environment variables into the Registry so the Processes can find them.
After you reboot and run the DoNet Bechmarks again and you should see the results as shown in the image below:
If you are wondering where the ./BenchmarkDotNet.Artifacts folder is to find the reports, navigate to the bin folder then Release then the version of DotNet you are running. You should see the BenchmarkDotNet.Artifacts folder, see the image below:
Navigating to that folder, you will see the plot.png, in the bar graph below you see that the for loop with arrays is faster than
for loop with a List.
See the results below for loop with an Array vs List:
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19043.1826 (21H1/May2021Update)
AMD Ryzen 9 3950X, 1 CPU, 32 logical and 16 physical cores
.NET SDK=6.0.301
[Host] : .NET 6.0.6 (6.0.622.26707), X64 RyuJIT [AttachedDebugger]
Server=True Toolchain=InProcessEmitToolchain
| Method | Mean | Error | StdDev | StdErr | Min | Max | Q1 | Q3 | Median | Op/s | Rank | Gen 0 | Gen 1 | Gen 2 | Allocated |
|----------------------------- |---------:|--------:|---------:|--------:|---------:|---------:|---------:|---------:|---------:|--------:|-----:|---------:|---------:|---------:|----------:|
| 'For lopp with List<int>' | 491.3 us | 9.75 us | 28.30 us | 2.87 us | 446.7 us | 560.2 us | 465.8 us | 508.0 us | 488.3 us | 2,035.3 | 2 | 285.1563 | 285.1563 | 285.1563 | 1,025 KB |
| 'For lopp with Array of Int' | 165.9 us | 3.29 us | 6.34 us | 0.94 us | 153.2 us | 178.2 us | 160.3 us | 171.6 us | 166.1 us | 6,028.4 | 1 | 124.7559 | 124.7559 | 124.7559 | 391 KB |