Esempio n. 1
0
        private async Task <PerformanceReport> DoExternalSort(string pathToSourceFile, string targetFileName)
        {
            using var runRepository = _repositoryProvider.CreateNewRepository();

            var performanceReport = new PerformanceReport();
            var stopwatch         = Stopwatch.StartNew();

            await _fileSplitter.Split(
                pathToSourceFile : pathToSourceFile,
                repository : runRepository,
                runSizeHintInBytes : GetRunSizeHint(),
                lineLengthHintInBytes : 24,
                maxDegreeOfParallelism : GetDegreeOfParallelism()
                );

            stopwatch.Stop();
            performanceReport.SplitTime = stopwatch.Elapsed;

            stopwatch = Stopwatch.StartNew();

            await MergeSortedRuns(runRepository, targetFileName);

            stopwatch.Stop();
            performanceReport.MergeTime = stopwatch.Elapsed;

            return(performanceReport);
        }
Esempio n. 2
0
        private void LogPerformanceInfo(PerformanceReport perfReport)
        {
            var timeTaken    = perfReport.TotalTime;
            var totalSeconds = timeTaken.TotalSeconds;

            _logger($"Sorted the file '{_sourceFilePath}' in {timeTaken}/{totalSeconds:0.##} seconds.");
        }