public void GlobalSetup()
 {
     foreach (var message in _messages)
     {
         var stream = new MemoryStream();
         // Note: we copy into a memory stream to try and make things fair for
         // MailSystem.NET which can only parse MemoryStreams or byte[] data.
         using (var file = File.OpenRead(message))
         {
             // Note: convert to DOS line endings in case the benchmark
             // is being run on Mac or Linux
             using (var filtered = new MimeKit.IO.FilteredStream(stream))
             {
                 filtered.Add(new MimeKit.IO.Filters.Unix2DosFilter());
                 file.CopyTo(filtered);
                 filtered.Flush();
             }
         }
         stream.Position = 0;
         _streams.Add(stream);
     }
 }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            var       messages = new [] { "startrek.msg", "xamarin3.msg" };
            const int count    = 1000;          // the number of times to parse the message

            foreach (var message in messages)
            {
                using (var stream = new MemoryStream()) {
                    // Note: we copy into a memory stream to try and make things fair for
                    // MailSystem.NET which can only parse MemoryStreams or byte[] data.
                    using (var file = File.OpenRead(message)) {
                        // Note: convert to DOS line endings in case the benchmark
                        // is being run on Mac or Linux
                        using (var filtered = new MimeKit.IO.FilteredStream(stream)) {
                            filtered.Add(new MimeKit.IO.Filters.Unix2DosFilter());
                            file.CopyTo(filtered);
                            filtered.Flush();
                        }
                    }
                    stream.Position = 0;

                    Console.WriteLine("Parsing {0} ({1} iterations):", message, count);

                    Console.WriteLine("MimeKit:        {0} seconds", MeasureMimeKit(stream, count).TotalSeconds);
                    Console.WriteLine("Mime4Net:       {0} seconds", MeasureMime4Net(stream, count).TotalSeconds);
                    Console.WriteLine("OpenPop:        {0} seconds", MeasureOpenPOP(stream, count).TotalSeconds);
                    Console.WriteLine("AE.Net.Mail:    {0} seconds", MeasureAENetMail(stream, count).TotalSeconds);
                    Console.WriteLine("MailSystem.NET: {0} seconds", MeasureMailSystemNET(stream, count).TotalSeconds);
                    Console.WriteLine("MIMER:          {0} seconds", MeasureMIMER(stream, count).TotalSeconds);
                }

                Console.WriteLine();
            }

            Console.ReadLine();
        }