Ejemplo n.º 1
0
        public static void TestSpeedParallelForConcurrencyBag()
        {
            var allLines         = File.ReadAllLines(_filePath);
            int linesToProcess   = allLines.Length;
            var parsedLogEntries = new ConcurrentBag <ApacheLogEntry>();

            Stopwatch sw = new Stopwatch();

            sw.Start();

            Parallel.For(0, linesToProcess, i => parsedLogEntries.Add(ApacheLogAnalyser.GetLogEntryFromString(allLines[i])));

            sw.Stop();
            Console.WriteLine("TestSpeedParallelForConcurrencyBag() Time: {0} ms, Count: {1}", sw.Elapsed.TotalMilliseconds, parsedLogEntries.Count);
        }
Ejemplo n.º 2
0
        public static void TestSpeedForeachList()
        {
            var allLines         = File.ReadAllLines(_filePath);
            var parsedLogEntries = new List <ApacheLogEntry>();

            Stopwatch sw = new Stopwatch();

            sw.Start();

            foreach (var line in allLines)
            {
                parsedLogEntries.Add(ApacheLogAnalyser.GetLogEntryFromString(line));
            }


            sw.Stop();
            Console.WriteLine("TestSpeedForeachList() Time: {0} ms, Count: {1}", sw.Elapsed.TotalMilliseconds, parsedLogEntries.Count);
        }
Ejemplo n.º 3
0
        public void TestGetLogEntryFromString(string str)
        {
            var entry = ApacheLogAnalyser.GetLogEntryFromString(str);

            Assert.Equal(entry.Response, 200);
        }