Aspectacular.Test.RunCounter.SpinParallelPerSec C# (CSharp) Method

SpinParallelPerSec() public static method

Runs a function for given time span, and return average runs per second. Number of tasks spawned matches number of logical processors.
public static SpinParallelPerSec ( long millisecondsToRun, System.Action funcToTest ) : long
millisecondsToRun long
funcToTest System.Action
return long
        public static long SpinParallelPerSec(long millisecondsToRun, Action funcToTest)
        {
            long count = SpinParallel(millisecondsToRun, funcToTest);
            long runsPerSec = count/(millisecondsToRun/1000);
            return runsPerSec;
        }

Usage Example

Example #1
0
        public void CallConstStaticPerfCounter()
        {
            const int baseLineMultiThreadConstStaticParmRunsPerSec  = 23000; // 31500; // 33500;
            const int baseLineSingleThreadConstStaticParmRunsPerSec = 8500;  // 9000

            long runsPerSec;

            runsPerSec = RunCounter.SpinParallelPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(123, "bogus", false, 1m, null)));
            this.TestContext.WriteLine("DoNothingStatic() STATIC PROXIED PARALLEL LOCALVARS CONSTANTPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineMultiThreadConstStaticParmRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineMultiThreadConstStaticParmRunsPerSec);

            runsPerSec = RunCounter.SpinPerSec(MillisecToRun, () => AOP.Invoke(() => SomeTestClass.DoNothingStatic(123, "bogus", false, 1m, null)));
            this.TestContext.WriteLine("DoNothingStatic() STATIC PROXIED SEQUENTIAL CONSTANTPARAMS got {0} cps, with expected {1} cps.", runsPerSec, baseLineSingleThreadConstStaticParmRunsPerSec);
            //Assert.IsTrue(runsPerSec >= baseLineSingleThreadConstStaticParmRunsPerSec);
        }
All Usage Examples Of Aspectacular.Test.RunCounter::SpinParallelPerSec