public void IO_Write_Test(CpuUsageScope scope)
        {
            if (!PosixResourceUsage.IsSupported)
            {
                return;
            }
            if (scope == CpuUsageScope.Thread && CrossInfo.ThePlatform != CrossInfo.Platform.Linux)
            {
                return;
            }

            // Arrange: nothing to do

            // Act
            PosixResourceUsage before = PosixResourceUsage.GetByScope(scope).Value;
            var numBytes = 10 * 512 * 1024;

            WriteFile(numBytes);
            PosixResourceUsage after = PosixResourceUsage.GetByScope(scope).Value;
            var delta = PosixResourceUsage.Substruct(after, before);

            Console.WriteLine($"Operation: write {numBytes:n0} bytes. ReadOps = {delta.ReadOps}. WriteOps = {delta.WriteOps}");

            // Assert
            if (CrossInfo.ThePlatform != CrossInfo.Platform.Linux)
            {
                return;
            }
            if (SkipPosixResourcesUsageAsserts || !IsIoReadsWritesSupported())
            {
                return;
            }
            Assert.Greater(delta.WriteOps, 0);
        }
 public void Smoke_Test(CpuUsageScope scope)
 {
     if (!PosixResourceUsage.IsSupported)
     {
         return;
     }
     Console.WriteLine($"PosixResourceUsage.GetByScope({scope}): {PosixResourceUsage.GetByScope(scope)}");
 }
        public void ContextSwitch_Test(CpuUsageScope scope, int expectedSwitchCount)
        {
            if (!PosixResourceUsage.IsSupported)
            {
                return;
            }
            if (scope == CpuUsageScope.Thread && CrossInfo.ThePlatform != CrossInfo.Platform.Linux)
            {
                return;
            }

            // Act
            PosixResourceUsage before = PosixResourceUsage.GetByScope(scope).Value;

            for (int i = 0; i < expectedSwitchCount; i++)
            {
                // CpuLoader.Run(1, 0, true);
                Stopwatch sw = Stopwatch.StartNew();
                while (sw.ElapsedMilliseconds < 1)
                {
                    ;
                }
                // on some build server sometimes fails (Azure - sometimes fail, AppVeyor - OK)
                Thread.Sleep(3);
            }

            PosixResourceUsage after = PosixResourceUsage.GetByScope(scope).Value;
            // var delta = PosixResourceUsage.Substruct(after, before);
            var delta = after - before;

            Console.WriteLine($"delta.InvoluntaryContextSwitches = {delta.InvoluntaryContextSwitches}");
            Console.WriteLine($"delta.VoluntaryContextSwitches = {delta.VoluntaryContextSwitches}");

            // Assert
            if (CrossInfo.ThePlatform != CrossInfo.Platform.Linux)
            {
                return;
            }
            if (SkipPosixResourcesUsageAsserts)
            {
                return;
            }
            Assert.IsTrue(expectedSwitchCount <= delta.VoluntaryContextSwitches && expectedSwitchCount <= delta.VoluntaryContextSwitches + 7);
//            if (scope == CpuUsageScope.Thread)
//                Assert.IsTrue(expectedSwitchCount == delta.VoluntaryContextSwitches || expectedSwitchCount == delta.VoluntaryContextSwitches - 1);
//            else
//                Assert.GreaterOrEqual(delta.VoluntaryContextSwitches, expectedSwitchCount);
        }