示例#1
0
        public TimerValue Scale(TimeUnit rate, TimeUnit duration)
        {
            var durationFactor = _durationUnit.ScalingFactorFor(duration);
            var total          = _durationUnit.Convert(duration, TotalTime);

            return(new TimerValue(Rate.Scale(rate), Histogram.Scale(durationFactor), ActiveSessions, total, duration));
        }
        /// <summary>
        /// A case where we don't have specific iteration time.
        /// </summary>
        private long RunAuto()
        {
            long   invokeCount      = TargetAccuracy.MinInvokeCount.Resolve(Resolver);
            double maxError         = TargetAccuracy.MaxStdErrRelative.Resolve(Resolver); // TODO: introduce a StdErr factor
            double minIterationTome = TimeUnit.Convert(Engine.MinIterationTimeMs, TimeUnit.Millisecond, TimeUnit.Nanosecond);

            double resolution = TargetClock.GetResolution().Nanoseconds;

            int iterationCounter = 0;

            while (true)
            {
                iterationCounter++;
                var    measurement       = RunIteration(IterationMode.Pilot, iterationCounter, invokeCount);
                double iterationTime     = measurement.Nanoseconds;
                double operationError    = 2.0 * resolution / invokeCount;         // An operation error which has arisen due to the Chronometer precision
                double operationMaxError = iterationTime / invokeCount * maxError; // Max acceptable operation error

                bool isFinished = operationError < operationMaxError && iterationTime >= minIterationTome;
                if (isFinished)
                {
                    break;
                }
                if (invokeCount >= MaxInvokeCount)
                {
                    break;
                }

                invokeCount *= 2;
            }
            WriteLine();

            return(invokeCount);
        }
示例#3
0
        public static string ToTimeStr(this double value, TimeUnit unit = null, int unitNameWidth = 1)
        {
            unit = unit ?? TimeUnit.GetBestTimeUnit(value);
            var unitValue = TimeUnit.Convert(value, TimeUnit.Nanoseconds, unit);
            var unitName  = unit.Name.PadLeft(unitNameWidth);

            return($"{unitValue.ToStr("N4")} {unitName}");
        }
        private void CheckConvertOneWay(double value1, TimeUnit unit1, double value2, TimeUnit unit2)
        {
            var convertedValue2 = TimeUnit.Convert(value1, unit1, unit2);

            output.WriteLine($"Expected: {value1} {unit1.Name} = {value2} {unit2.Name}");
            output.WriteLine($"Actual: {value1} {unit1.Name} = {convertedValue2} {unit2.Name}");
            output.WriteLine("");
            Assert.Equal(value2, convertedValue2, 4);
        }
示例#5
0
 private long ToExcessNanos(long days)
 {
     if (Unit != null)
     {
         return(Unit.ToNanos(Value - Unit.Convert(days, TimeUnit.DAYS)));
     }
     else
     {
         return(TimeUnit.SECONDS.ToNanos(ToInstant().EpochSecond - TimeUnit.DAYS.ToSeconds(days)));
     }
 }
示例#6
0
        /// <inheritdoc />
        public void Record(long duration, TimeUnit unit, string userValue)
        {
            var time = unit.Convert(_timeUnit, duration);

            if (time < 0)
            {
                return;
            }

            _histogram.Update(time, userValue);
            _meter.Mark();
        }
示例#7
0
        public static string ToTimeStr(this double value, TimeUnit unit = null, int unitNameWidth = 1, bool showUnit = true, string format = "N4",
                                       Encoding encoding = null)
        {
            unit = unit ?? TimeUnit.GetBestTimeUnit(value);
            double unitValue = TimeUnit.Convert(value, TimeUnit.Nanosecond, unit);

            if (showUnit)
            {
                string unitName = unit.Name.ToString(encoding ?? Encoding.ASCII).PadLeft(unitNameWidth);
                return($"{unitValue.ToStr(format)} {unitName}");
            }

            return($"{unitValue.ToStr(format)}");
        }
示例#8
0
        public static string ToTimeStr(this double value, TimeUnit unit = null, int unitNameWidth = 1, bool showUnit = true, string format = "N4")
        {
            unit = unit ?? TimeUnit.GetBestTimeUnit(value);
            var unitValue = TimeUnit.Convert(value, TimeUnit.Nanosecond, unit);

            if (showUnit)
            {
                var unitName = unit.Name.PadLeft(unitNameWidth);
                return($"{unitValue.ToStr(format)} {unitName}");
            }
            else
            {
                return($"{unitValue.ToStr(format)}");
            }
        }
示例#9
0
 /// <summary>
 /// Returns the value at the given unit of granularity.
 ///
 /// <para> Conversion from a coarser granularity that would numerically overflow
 /// saturate to {@code Long.MIN_VALUE} if negative or {@code Long.MAX_VALUE}
 /// if positive.
 ///
 /// </para>
 /// </summary>
 /// <param name="unit">
 ///          the unit of granularity for the return value
 /// </param>
 /// <returns>  value in the given unit of granularity, since the epoch
 ///          since the epoch (1970-01-01T00:00:00Z); can be negative </returns>
 public long To(TimeUnit unit)
 {
     Objects.RequireNonNull(unit, "unit");
     if (this.Unit != null)
     {
         return(unit.Convert(this.Value, this.Unit));
     }
     else
     {
         long secs = unit.Convert(Instant.EpochSecond, TimeUnit.SECONDS);
         if (secs == Long.MinValue || secs == Long.MaxValue)
         {
             return(secs);
         }
         long nanos = unit.Convert(Instant.Nano, TimeUnit.NANOSECONDS);
         long r     = secs + nanos;
         // Math.addExact() variant
         if (((secs ^ r) & (nanos ^ r)) < 0)
         {
             return((secs < 0) ? Long.MinValue : Long.MaxValue);
         }
         return(r);
     }
 }
示例#10
0
        /// <summary>
        /// Starts the reporting task for periodic output
        /// </summary>
        /// <param name="period">The period between successive displays</param>
        /// <param name="unit">The period time unit</param>
        public virtual void Start(long period, TimeUnit unit)
        {
            var seconds  = unit.Convert(period, TimeUnit.Seconds);
            var interval = TimeSpan.FromSeconds(seconds);

            Token = new CancellationTokenSource();
            Task.Factory.StartNew(() =>
            {
                OnStarted();
                while (!Token.IsCancellationRequested)
                {
                    Thread.Sleep(interval);
                    Run();
                }
            }, Token.Token);
        }
示例#11
0
        /// <summary>
        /// Starts the reporting task for periodic output
        /// </summary>
        /// <param name="period">The period between successive displays</param>
        /// <param name="unit">The period time unit</param>
        public virtual void Start(long period, TimeUnit unit)
        {
            var seconds = unit.Convert(period, TimeUnit.Seconds);
            var interval = TimeSpan.FromSeconds(seconds);

            Token = new CancellationTokenSource();
            Task.Factory.StartNew(() =>
            {
                OnStarted();
                while (!Token.IsCancellationRequested)
                {
                    Thread.Sleep(interval);
                    Run();
                }
            }, Token.Token);
        }
        private static long RunPilot(Func <MultiInvokeInput, Measurement> multiInvoke, Count iterationTime)
        {
            long invokeCount = MinInvokeCount;

            if (iterationTime.IsAuto)
            {
                var resolution       = Chronometer.GetResolution();
                int iterationCounter = 0;
                while (true)
                {
                    iterationCounter++;
                    var measurement = multiInvoke(new MultiInvokeInput(IterationMode.Pilot, iterationCounter, invokeCount));
                    if (resolution / invokeCount <
                        measurement.GetAverageNanoseconds() * TargetMainAutoMaxAcceptableError &&
                        measurement.Nanoseconds > TimeUnit.Convert(MinIterationTimeMs, TimeUnit.Millisecond, TimeUnit.Nanoseconds))
                    {
                        break;
                    }
                    invokeCount *= 2;
                }
            }
            else
            {
                var iterationTimeInNanoseconds = TimeUnit.Convert(iterationTime, TimeUnit.Millisecond, TimeUnit.Nanoseconds);
                int iterationCounter           = 0;
                int downCount = 0;
                while (true)
                {
                    iterationCounter++;
                    var measurement    = multiInvoke(new MultiInvokeInput(IterationMode.Pilot, iterationCounter, invokeCount));
                    var newInvokeCount = Math.Max(
                        5, (long)Math.Round(invokeCount * iterationTimeInNanoseconds / measurement.Nanoseconds));
                    if (newInvokeCount < invokeCount)
                    {
                        downCount++;
                    }
                    if (Math.Abs(newInvokeCount - invokeCount) <= 1 || downCount >= 3)
                    {
                        break;
                    }
                    invokeCount = newInvokeCount;
                }
            }
            Console.WriteLine();
            return(invokeCount);
        }
        public Future <T> Schedule <T> (Runnable r, long delay, TimeUnit unit)
        {
            DateTime now = DateTime.Now;

            lock (this) {
                if (IsShutdown())
                {
                    return(null);
                }
                Task <T> t = new Task <T> ()
                {
                    Executor = this,
                    Action   = r,
                    DueTime  = now + TimeSpan.FromMilliseconds(unit.Convert(delay, TimeUnit.MILLISECONDS))
                };
                Scheduler.Instance.AddTask(t);
                return(t);
            }
        }
示例#14
0
        /// <summary>
        /// Starts the reporting task for periodic output
        /// </summary>
        /// <param name="period">The period between successive displays</param>
        /// <param name="unit">The period time unit</param>
        public virtual void Start(long period, TimeUnit unit)
        {
            var seconds  = unit.Convert(period, TimeUnit.Seconds);
            var interval = TimeSpan.FromSeconds(seconds);

            _token = new CancellationTokenSource();
            Task.Run(async() =>
            {
                OnStarted();
                while (!_token.IsCancellationRequested)
                {
                    await Task.Delay(interval, _token.Token);
                    if (!_token.IsCancellationRequested)
                    {
                        Run();
                    }
                }
            }, _token.Token);
        }
        public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style)
        {
            var type   = benchmarkCase.Descriptor.Type;
            var report = summary[benchmarkCase];

            if (!type.IsSubclassOf(typeof(APredefinedBenchmark)))
            {
                return(string.Empty);
            }

            if (!report.Success || !report.BuildResult.IsBuildSuccess || report.ExecuteResults.Count == 0)
            {
                return("NA");
            }

            var instance = (APredefinedBenchmark)Activator.CreateInstance(type);

            if (instance == null)
            {
                return("NA");
            }

            var paramInstances = benchmarkCase.Parameters;

            instance.MessageTarget = UpdateInstanceValueSave(instance.MessageTarget, paramInstances, nameof(instance.MessageTarget));

            int messageCount = instance.MessageTarget;
            var statistics   = report.ResultStatistics;
            var meanSeconds  = TimeUnit.Convert(statistics.Mean, TimeUnit.Nanosecond, TimeUnit.Second);
            var msgPerSecond = messageCount / meanSeconds;


            var cultureInfo = summary.GetCultureInfo();

            if (style.PrintUnitsInContent)
            {
                return(msgPerSecond.ToString("N0", cultureInfo) + " msg/s");
            }

            return(msgPerSecond.ToString("N0", cultureInfo));
        }
示例#16
0
 /// <exception cref="System.Exception"></exception>
 /// <exception cref="Sharpen.ExecutionException"></exception>
 /// <exception cref="Sharpen.TimeoutException"></exception>
 public virtual T Get(long timeout, TimeUnit unit)
 {
     lock (this)
     {
         Args.NotNull(unit, "Time unit");
         long msecs     = unit.Convert(timeout, TimeUnit.MILLISECONDS);
         long startTime = (msecs <= 0) ? 0 : Runtime.CurrentTimeMillis();
         long waitTime  = msecs;
         if (this.completed)
         {
             return(GetResult());
         }
         else
         {
             if (waitTime <= 0)
             {
                 throw new TimeoutException();
             }
             else
             {
                 for (; ;)
                 {
                     Sharpen.Runtime.Wait(this, waitTime);
                     if (this.completed)
                     {
                         return(GetResult());
                     }
                     else
                     {
                         waitTime = msecs - (Runtime.CurrentTimeMillis() - startTime);
                         if (waitTime <= 0)
                         {
                             throw new TimeoutException();
                         }
                     }
                 }
             }
         }
     }
 }
示例#17
0
        /// <summary>
        /// Starts the reporting task for periodic output
        /// </summary>
        /// <param name="period">The period between successive displays</param>
        /// <param name="unit">The period time unit</param>
        public virtual void Start(long period, TimeUnit unit)
        {
            var seconds = unit.Convert(period, TimeUnit.Seconds);
            var interval = TimeSpan.FromSeconds(seconds);

            Token = Utils.StartCancellableTask(() =>
            {
                OnStarted();
                while (!Token.IsCancellationRequested)
                {
                    Thread.Sleep(interval);
                    Run();
                }
            });
        }
            /// <summary>Get the delay until this event should happen.</summary>
            public virtual long GetDelay(TimeUnit unit)
            {
                long millisLeft = renewalTime - Time.Now();

                return(unit.Convert(millisLeft, TimeUnit.Milliseconds));
            }
 public RecencyBoostScorerBuilder(string timeFacetName, float maxFactor, long cutoff, TimeUnit timeunit)
     : this(timeFacetName, maxFactor, timeunit.Convert(System.Environment.TickCount, TimeUnit.MILLISECONDS), cutoff, timeunit)
 {  
 }
示例#20
0
 public RecencyBoostScorerBuilder(string timeFacetName, float maxFactor, long cutoff, TimeUnit timeunit)
     : this(timeFacetName, maxFactor, timeunit.Convert(System.Environment.TickCount, TimeUnit.MILLISECONDS), cutoff, timeunit)
 {
 }
示例#21
0
 /// <summary>
 /// Convert the specified time duration in the given unit to the
 /// nanoseconds units.
 /// </summary>
 /// <returns></returns>
 public static double ToSeconds(this TimeUnit @from, int duration)
 {
     return(@from.Convert(duration, TimeUnit.Seconds));
 }
        public static Summary Run(BenchmarkRunInfo benchmarkRunInfo, ILogger logger, string title, string rootArtifactsFolderPath, Func <Job, IToolchain> toolchainProvider, IResolver resolver, List <string> artifactsToCleanup)
        {
            var benchmarks = benchmarkRunInfo.Benchmarks;
            var config     = benchmarkRunInfo.Config;

            logger.WriteLineHeader("// ***** BenchmarkRunner: Start   *****");
            logger.WriteLineInfo("// Found benchmarks:");
            foreach (var benchmark in benchmarks)
            {
                logger.WriteLineInfo($"//   {benchmark.DisplayInfo}");
            }
            logger.WriteLine();

            var validationErrors = Validate(benchmarks, logger, config);

            if (validationErrors.Any(validationError => validationError.IsCritical))
            {
                return(Summary.CreateFailed(benchmarks, title, HostEnvironmentInfo.GetCurrent(), config, GetResultsFolderPath(rootArtifactsFolderPath), validationErrors));
            }

            var globalChronometer = Chronometer.Start();
            var reports           = new List <BenchmarkReport>();

            var buildResults = BuildInParallel(logger, rootArtifactsFolderPath, toolchainProvider, resolver, benchmarks, config, ref globalChronometer);

            foreach (var benchmark in benchmarks)
            {
                var buildResult = buildResults[benchmark];

                if (!config.KeepBenchmarkFiles)
                {
                    artifactsToCleanup.AddRange(buildResult.ArtifactsToCleanup);
                }

                if (buildResult.IsBuildSuccess)
                {
                    var report = RunCore(benchmark, logger, config, rootArtifactsFolderPath, toolchainProvider, resolver, buildResult);
                    reports.Add(report);
                    if (report.GetResultRuns().Any())
                    {
                        logger.WriteLineStatistic(report.GetResultRuns().GetStatistics().ToTimeStr());
                    }
                }
                else
                {
                    reports.Add(new BenchmarkReport(benchmark, buildResult, buildResult, null, null, default));

                    if (buildResult.GenerateException != null)
                    {
                        logger.WriteLineError($"// Generate Exception: {buildResult.GenerateException.Message}");
                    }
                    if (buildResult.BuildException != null)
                    {
                        logger.WriteLineError($"// Build Exception: {buildResult.BuildException.Message}");
                    }
                }

                logger.WriteLine();
            }
            var clockSpan = globalChronometer.GetElapsed();

            var summary = new Summary(title, reports, HostEnvironmentInfo.GetCurrent(), config, GetResultsFolderPath(rootArtifactsFolderPath), clockSpan.GetTimeSpan(), validationErrors);

            logger.WriteLineHeader("// ***** BenchmarkRunner: Finish  *****");
            logger.WriteLine();

            logger.WriteLineHeader("// * Export *");
            var currentDirectory = Directory.GetCurrentDirectory();

            foreach (var file in config.GetCompositeExporter().ExportToFiles(summary, logger))
            {
                logger.WriteLineInfo($"  {file.Replace(currentDirectory, string.Empty).Trim('/', '\\')}");
            }
            logger.WriteLine();

            logger.WriteLineHeader("// * Detailed results *");

            // TODO: make exporter
            foreach (var report in reports)
            {
                logger.WriteLineInfo(report.Benchmark.DisplayInfo);
                logger.WriteLineStatistic($"Runtime = {report.GetRuntimeInfo()}; GC = {report.GetGcInfo()}");
                var resultRuns = report.GetResultRuns();
                if (resultRuns.IsEmpty())
                {
                    logger.WriteLineError("There are not any results runs");
                }
                else
                {
                    logger.WriteLineStatistic(resultRuns.GetStatistics().ToTimeStr());
                }
                logger.WriteLine();
            }

            LogTotalTime(logger, clockSpan.GetTimeSpan());
            logger.WriteLine();

            logger.WriteLineHeader("// * Summary *");
            MarkdownExporter.Console.ExportToLog(summary, logger);

            // TODO: make exporter
            ConclusionHelper.Print(logger, config.GetCompositeAnalyser().Analyse(summary).ToList());

            // TODO: move to conclusions
            var columnWithLegends = summary.Table.Columns.Select(c => c.OriginalColumn).Where(c => !string.IsNullOrEmpty(c.Legend)).ToList();
            var effectiveTimeUnit = summary.Table.EffectiveSummaryStyle.TimeUnit;

            if (columnWithLegends.Any() || effectiveTimeUnit != null)
            {
                logger.WriteLine();
                logger.WriteLineHeader("// * Legends *");
                int maxNameWidth = 0;
                if (columnWithLegends.Any())
                {
                    maxNameWidth = Math.Max(maxNameWidth, columnWithLegends.Select(c => c.ColumnName.Length).Max());
                }
                if (effectiveTimeUnit != null)
                {
                    maxNameWidth = Math.Max(maxNameWidth, effectiveTimeUnit.Name.Length + 2);
                }

                foreach (var column in columnWithLegends)
                {
                    logger.WriteLineHint($"  {column.ColumnName.PadRight(maxNameWidth, ' ')} : {column.Legend}");
                }

                if (effectiveTimeUnit != null)
                {
                    logger.WriteLineHint($"  {("1 " + effectiveTimeUnit.Name).PadRight(maxNameWidth, ' ')} :" +
                                         $" 1 {effectiveTimeUnit.Description} ({TimeUnit.Convert(1, effectiveTimeUnit, TimeUnit.Second).ToStr("0.#########")} sec)");
                }
            }

            if (config.GetDiagnosers().Any())
            {
                logger.WriteLine();
                config.GetCompositeDiagnoser().DisplayResults(logger);
            }

            logger.WriteLine();
            logger.WriteLineHeader("// ***** BenchmarkRunner: End *****");
            return(summary);
        }
示例#23
0
        public double Measure(MetricConfig config, long now)
        {
            double value = internalStat.Measure(config, now);

            return(value / timeUnit.Convert(WindowSize(config, now)));
        }
示例#24
0
            public virtual long GetDelay(TimeUnit unit)
            {
                long n = this.delayTime - Runtime.CurrentTimeMillis();

                return(unit.Convert(n, TimeUnit.Milliseconds));
            }
示例#25
0
 /// <summary>
 /// Convert the specified time duration in the given unit to the
 /// nanoseconds units.
 /// </summary>
 /// <returns></returns>
 public static long ToTicks(this TimeUnit @from, double duration)
 {
     return((long)@from.Convert(duration, TimeUnit.Ticks));
 }
示例#26
0
        /// <summary>
        /// Starts printing output to the specified <see cref="TextWriter" />
        /// </summary>
        /// <param name="period">The period between successive displays</param>
        /// <param name="unit">The period time unit</param>
        public void Start(long period, TimeUnit unit)
        {
            var seconds = unit.Convert(period, TimeUnit.Seconds);
            var interval = TimeSpan.FromSeconds(seconds);

            if(_tickThread != null)
            {
                _tickThread.Abort();
            }

            _tickThread = _factory.New(
                () =>
                    {
                        new Timer(s => Run(), null, interval, interval);
                    }
                );
            _tickThread.Start();
        }
示例#27
0
            public virtual long GetDelay(TimeUnit unit)
            {
                long remainingTime = endTime - Time.MonotonicNow();

                return(unit.Convert(remainingTime, TimeUnit.Milliseconds));
            }
示例#28
0
        public static async Task Main(string[] args)
        {
            try
            {
                _fileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);

                Console.WriteLine($"Initializing NCompileBench. Version: {_fileVersionInfo.ProductVersion}");
                Console.WriteLine($"Run with -verbose flag to see more details during the benchmark");
                Console.WriteLine($"Run with -submit to submit your latest benchmark");
                Console.WriteLine($"Run with -autosubmit to automatically submit your latest benchmark. If used together with -submit, previous benchmark result is submitted");
                Console.WriteLine($"Run with -scores to view the online results without running the benchmark");
                Console.WriteLine($"Run with -nomaxiterations to get even more accurate results. Please view readme for more details");
                Console.WriteLine("****");
                Console.WriteLine($"Results and help available from: https://www.ncompilebench.io");
                Console.WriteLine($"Created by Mikael Koskinen: https://mikaelkoskinen.net");
                Console.WriteLine($"Source code available from https://github.com/mikoskinen/NCompileBench (MIT)");
                Console.WriteLine($"Based on .NET Performance repository: https://github.com/dotnet/performance by Microsoft (MIT)");
                Console.WriteLine($"Uses BenchmarkDotNet: https://github.com/dotnet/BenchmarkDotNet (MIT)");
                Console.WriteLine($"Compiles source code available from https://github.com/dotnet/roslyn/releases/tag/perf-assets-v1");
                Console.WriteLine("****");

                var directoryName   = Path.GetDirectoryName(typeof(Program).Assembly.Location);
                var resultDirectory = Path.Combine(directoryName, "results");

                var submit     = args?.Any(x => string.Equals(x, "-submit", StringComparison.InvariantCultureIgnoreCase)) == true;
                var autoSubmit = args?.Any(x => string.Equals(x, "-autosubmit", StringComparison.InvariantCultureIgnoreCase)) == true;

                if (submit)
                {
                    await HandleSubmit(resultDirectory, autoSubmit);

                    return;
                }

                var scores = args?.Any(x => string.Equals(x, "-scores", StringComparison.InvariantCultureIgnoreCase)) == true;

                if (scores)
                {
                    await HandleScores();

                    return;
                }

                Console.WriteLine("Setting up the benchmark");

                await Setup();

                Console.WriteLine("Starting benchmark in 5 seconds. Please sit tight, this may take up-to 10 minutes");

                await Task.Delay(TimeSpan.FromSeconds(5));

                var verbose         = args?.Any(x => string.Equals(x, "-verbose", StringComparison.InvariantCultureIgnoreCase)) == true;
                var noMaxIterations = args?.Any(x => string.Equals(x, "-nomaxiterations", StringComparison.InvariantCultureIgnoreCase)) == true;

                var cts = new CancellationTokenSource();

                if (verbose == false)
                {
                    ThreadPool.QueueUserWorkItem(Spin, cts.Token);
                }

                var artifactsPath = new DirectoryInfo(directoryName);
                var config        = BenchmarkConfig.Create(artifactsPath, verbose, noMaxIterations);

                var summary = BenchmarkRunner.Run <CompilationBenchmarks>(config);
                cts.Cancel();

                await Task.Delay(TimeSpan.FromMilliseconds(750));

                Console.WriteLine("****");

                var nonConcurrentResult = summary.Reports.Single(x => (bool)x.BenchmarkCase.Parameters[0].Value == false)
                                          .ResultStatistics;

                var concurrentResult = summary.Reports.Single(x => (bool)x.BenchmarkCase.Parameters[0].Value == true)
                                       .ResultStatistics;

                var nonConcurrentTimespan = TimeSpan.FromMilliseconds(TimeUnit.Convert(nonConcurrentResult.Mean, TimeUnit.Nanosecond, TimeUnit.Millisecond));

                var concurrentTimespan =
                    TimeSpan.FromMilliseconds(TimeUnit.Convert(concurrentResult.Mean, TimeUnit.Nanosecond,
                                                               TimeUnit.Millisecond));

                var scoreMulti  = CalculateScore(concurrentTimespan);
                var scoreSingle = CalculateScore(nonConcurrentTimespan);
                Console.WriteLine($"NCompileBench Score: {scoreMulti} (non-concurrent score: {scoreSingle})");

                await DisplayComparisons();

                Console.WriteLine("****");
                Console.WriteLine("System information:");
                Console.WriteLine(summary.HostEnvironmentInfo.OsVersion.Value);

                Console.WriteLine(
                    $"{summary.HostEnvironmentInfo.CpuInfo.Value.ProcessorName}, {summary.HostEnvironmentInfo.CpuInfo.Value.PhysicalProcessorCount} CPU, {summary.HostEnvironmentInfo.CpuInfo.Value.LogicalCoreCount} logical and {summary.HostEnvironmentInfo.CpuInfo.Value.PhysicalCoreCount} physical cores");
                Console.WriteLine("****");
                Console.WriteLine($"More detailed results are available from {resultDirectory}");

                Console.WriteLine();

                if (CreateScore(scoreMulti, scoreSingle, resultDirectory))
                {
                    if (autoSubmit)
                    {
                        await HandleSubmit(resultDirectory, true);

                        return;
                    }

                    Console.WriteLine($"You can submit your benchmark by running ncompilebench -submit");
                    Console.WriteLine();
                }
            }
            finally
            {
                Console.WriteLine($"Thank you for running NCompileBench!");
            }
        }
示例#29
0
 /// <returns>current elapsed time in specified timeunit.</returns>
 public virtual long Now(TimeUnit timeUnit)
 {
     return(timeUnit.Convert(Now(), TimeUnit.Nanoseconds));
 }
示例#30
0
 /// <summary>
 /// Convert the specified time duration in the given unit to the
 /// nanoseconds units.
 /// </summary>
 public static double ToNanos(this TimeUnit @from, long duration)
 {
     return(@from.Convert(duration, TimeUnit.Nanoseconds));
 }
示例#31
0
 /// <summary>
 /// Convert the specified time duration in the given unit to the
 /// seconds units.
 /// </summary>
 /// <returns></returns>
 public static double ToMilliseconds(this TimeUnit @from, double duration)
 {
     return(@from.Convert(duration, TimeUnit.Milliseconds));
 }