Skip to content

Generate Exception: Access to the path '...' is denied. #1671

@msschl

Description

@msschl

When running BenchmarkDotNet with project files located on a second drive (SSD W:/) BenchmarkDotNet fails with Generate Exception: Access to the path 'W:\System Volume Information' is denied.

But when I copy all project files for example on my C:/ drive on my Desktop and run dotnet run -c Release there, then the benchmark runs without any problems...

λ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.201
 Commit:    a09bd5c86c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.201\

Host (useful for support):
  Version: 5.0.4
  Commit:  f27d337295

.NET SDKs installed:
  2.1.814 [C:\Program Files\dotnet\sdk]
  3.1.407 [C:\Program Files\dotnet\sdk]
  5.0.103 [C:\Program Files\dotnet\sdk]
  5.0.200-preview.21077.7 [C:\Program Files\dotnet\sdk]
  5.0.201 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
W:\test\microbenchmarks
λ dotnet run -c Release
Available Benchmarks:
  #0 BCDToInt32ConverterBenchmark
  #1 CharToKeyBenchmark
  #2 Int32ToBCDConverterBenchmark
  #3 ManufactureCodeConverterBenchmark
  #4 NormalizeStringBenchmark
  #5 ValidCharBenchmark
  #6 TransmuteObjectBenchmark


You should select the target benchmark(s). Please, print a number of a benchmark (e.g. `0`) or a contained benchmark caption (e.g. `BCDToInt32ConverterBenchmark`).
If you want to select few, please separate them with space ` ` (e.g. `1 2 3`).
You can also provide the class name in console arguments by using --filter. (e.g. `--filter *BCDToInt32ConverterBenchmark*`).
ManufactureCodeConverterBenchmark

// Validating benchmarks:
// ***** BenchmarkRunner: Start   *****
// ***** Found 2 benchmark(s) in total *****
// ***** Building 1 exe(s) in Parallel: Start   *****
// ***** Done, took 00:00:00 (0.11 sec)   *****
// Found 2 benchmarks:
//   ManufactureCodeConverterBenchmark.PlexItCoverter_BigByteToString: DefaultJob
//   ManufactureCodeConverterBenchmark.ToManufactureCode: DefaultJob

// Generate Exception: Access to the path 'W:\System Volume Information' is denied.

// Generate Exception: Access to the path 'W:\System Volume Information' is denied.

// ***** BenchmarkRunner: Finish  *****

// * Export *
  C:\tmp\results\Benchmarks.MicroBenchmarks.ManufactureCodeConverterBenchmark-report.csv
  C:\tmp\results\Benchmarks.MicroBenchmarks.ManufactureCodeConverterBenchmark-report-github.md
  C:\tmp\results\Benchmarks.MicroBenchmarks.ManufactureCodeConverterBenchmark-report.html

// * Detailed results *
ManufactureCodeConverterBenchmark.PlexItCoverter_BigByteToString: DefaultJob
Runtime = ; GC =
There are not any results runs

ManufactureCodeConverterBenchmark.ToManufactureCode: DefaultJob
Runtime = ; GC =
There are not any results runs

// * Summary *

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19042
Intel Core i7-6800K CPU 3.40GHz (Skylake), 1 CPU, 12 logical and 6 physical cores
.NET Core SDK=5.0.201
  [Host] : .NET Core 5.0.4 (CoreCLR 5.0.421.11614, CoreFX 5.0.421.11614), X64 RyuJIT


|                         Method | Mean | Error | Ratio | RatioSD |
|------------------------------- |-----:|------:|------:|--------:|
| PlexItCoverter_BigByteToString |   NA |    NA |     ? |       ? |
|              ToManufactureCode |   NA |    NA |     ? |       ? |

Benchmarks with issues:
  ManufactureCodeConverterBenchmark.PlexItCoverter_BigByteToString: DefaultJob
  ManufactureCodeConverterBenchmark.ToManufactureCode: DefaultJob

// * Warnings *
BaselineCustomAnalyzer
  Summary -> A question mark '?' symbol indicates that it was not possible to compute the (Ratio, RatioSD) column(s) because the baseline value is too close to zero.

// * Legends *
  Mean    : Arithmetic mean of all measurements
  Error   : Half of 99.9% confidence interval
  Ratio   : Mean of the ratio distribution ([Current]/[Baseline])
  RatioSD : Standard deviation of the ratio distribution ([Current]/[Baseline])
  1 ns    : 1 Nanosecond (0.000000001 sec)

// * Diagnostic Output - MemoryDiagnoser *


// ***** BenchmarkRunner: End *****
// ** Remained 0 benchmark(s) to run **
Run time: 00:00:00 (0.25 sec), executed benchmarks: 0

Global total time: 00:00:00 (0.37 sec), executed benchmarks: 0
// * Artifacts cleanup *

Benchmarks.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <OutputType>Exe</OutputType>
    <IsPackable>false</IsPackable>
    <IsTestProject>false</IsTestProject>
  </PropertyGroup>

  <PropertyGroup>
    <LangVersion>9.0</LangVersion>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
  </ItemGroup>

</Project>

Program.cs

using BenchmarkDotNet.Running;

namespace Benchmarks
{
    public class Program
    {
        public static void Main(string[] args) =>
            BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
    }
}

ManufactureCodeConverterBenchmark.cs

using System;
using System.Collections.Generic;

using BenchmarkDotNet.Attributes;

namespace Benchmarks.MicroBenchmarks
{
    [MemoryDiagnoser]
    public class ManufactureCodeConverterBenchmark
    {
        public static readonly byte[] TEST_BYTES_LITTLE_ENDIAN = new byte[] { 0x97, 0x26 };

        public const int Iterations = 100_000;

        [Benchmark(Description = "PlexItCoverter_BigByteToString", Baseline = true, OperationsPerInvoke = Iterations)]
        public void PlexItCoverter_BigByteToString()
        {
            for (var i = 0; i < Iterations; i++)
                _ = BigByteToString(TEST_BYTES_LITTLE_ENDIAN);
        }

        [Benchmark(Description = "ToManufactureCode", OperationsPerInvoke = Iterations)]
        public void ToManufactureCode()
        {
            for (var i = 0; i < Iterations; i++)
                _ = ToManufactureCode(TEST_BYTES_LITTLE_ENDIAN);
        }

        private static string ToManufactureCode(byte[] data)
        {
            if (data.Length != 2)
                throw new ArgumentException("The three letter manufacture code requires two bytes.", nameof(data));

            return String.Create<byte[]>(3, data, (span, data) =>
            {
                // Get the first five bits from the first byte (byte zero)
                var c3 = data[0] & 0x1F;

                // Get the remaining three bits of the first byte (byte zero) and two bits of the second byte (byte one)
                var c2 = ((data[0] >> 5) | (data[1] << 3)) & 0x1F;

                // Get the next five bits from the second byte (byte one)
                var c1 = (data[1] >> 2) & 0x1F;

                // Convert bits to characters by adding 64 back and casting to char
                span[2] = (char)(c3 + 64);
                span[1] = (char)(c2 + 64);
                span[0] = (char)(c1 + 64);
            });
        }

        public static string BigByteToString(byte[] bData)
        {
            // Daten jetzt in einen Integer wandeln
            int iValue = (bData[1] * 256) + bData[0];

            byte[] bChars = new byte[3];

            // Intwert auf 5Bit Basis zerlegen
            bChars[0] = (byte)(iValue / 1024);
            bChars[1] = (byte)((iValue - bChars[0] * 1024) / 32);
            bChars[2] = (byte)(iValue - bChars[0] * 1024 - bChars[1] * 32);

            // Jetzt noch 64 Addieren für die korrekte Verschiebung
            bChars[0] += 64;
            bChars[1] += 64;
            bChars[2] += 64;

            // Jetzt einen String aus den drei Chars erstellen
            // return plexxIT.Portable.Convert.CConvert.convertByteArraytoString(bChars);
            return System.Text.Encoding.Default.GetString(bChars);
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions