Esempio n. 1
0
        public void LogFile_Parsing_Performance()
        {
            const int Iterations = 1; // how many times we run parse the file

            TimeSpan  totalStream = TimeSpan.Zero;
            int       countStream = 0;
            Stopwatch sw          = new Stopwatch();

            var file = Configuration.UmbracoBigFile; // the big file to use

            /* This uses the stream version that reads one entry at a time */
            for (int i = 0; i < Iterations; i++)
            {
                sw.Reset();
                sw.Start();

                var logFile = Path.Combine(Configuration.TestLogsDirectory, file);

                LogDataService dataService = new LogDataService();

                countStream = dataService.GetLogDataFromFilePath(logFile)
                              //It's IEnumerable = lazy executed so we need to iterate it
                              .Count();
                sw.Stop();

                totalStream = totalStream.Add(sw.Elapsed);
            }

            Trace.Write("Elapsed Time Stream: " + totalStream);
        }
        public void LogFile_Profiling_Tests()
        {
            const int Iterations = 3; // how many times we run parse the file

            TimeSpan  totalStream  = TimeSpan.Zero;
            TimeSpan  totalReadAll = TimeSpan.Zero;
            Stopwatch sw           = new Stopwatch();

            var file = Configuration.UmbracoBigFile; // the big file to use

            /* This test uses the standard read all lines into memory */
            for (int i = 0; i < Iterations; i++)
            {
                sw.Reset();
                sw.Start();

                var logFile = Path.Combine(Configuration.TestLogsDirectory, file);

                LogDataService dataService = new LogDataService();

                var logData = dataService.GetLogDataFromFilePath(logFile);
                sw.Stop();

                totalReadAll = totalReadAll.Add(sw.Elapsed);
            }

            /* This uses the stream version that reads one entry at a time */
            for (int i = 0; i < Iterations; i++)
            {
                sw.Reset();
                sw.Start();

                var logFile = Path.Combine(Configuration.TestLogsDirectory, file);

                LogDataService dataService = new LogDataService();

                var logData = dataService.GetLogDataStreamFromFilePath(logFile);
                sw.Stop();

                totalStream = totalStream.Add(sw.Elapsed);
            }

            TestContext.WriteLine("Elapsed Time ReadAll: {0}\n", totalReadAll);

            TestContext.WriteLine("Elapsed Time Stream: {0}\n", totalStream);

            if (totalReadAll < totalStream)
            {
                TestContext.WriteLine("Read All is faster than Read Stream by {0}", totalStream - totalReadAll);
            }
            else
            {
                TestContext.WriteLine("Read Stream is faster than Read All by {0}", totalReadAll - totalStream);
            }
        }
Esempio n. 3
0
        public void Should_Read_Umbraco73x_LogFile()
        {
            var logFile = Path.Combine(Configuration.TestLogsDirectory, Configuration.Umbraco73xFile);

            LogDataService dataService = new LogDataService();

            var logData = dataService.GetLogDataFromFilePath(logFile);

            int logDataEntryCount = logData.Count();

            Assert.That(logDataEntryCount, Is.EqualTo(24), "The log data entry count should be 24 but is actually {0}", logDataEntryCount);
        }
Esempio n. 4
0
        public void Time_ParseLargeLogFile()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            var logFile = Path.Combine(Configuration.TestLogsDirectory, "UmbracoTraceLog.MictPHC124-PC.txt");

            LogDataService dataService = new LogDataService();

            var logData = dataService.GetLogDataFromFilePath(logFile).Count();

            sw.Stop();

            TestContext.WriteLine("Time taken: " + sw.Elapsed);
        }