Home

Awesome

MimeParserBenchmark

This project benchmarks various .NET MIME parsers for comparison purposes.

Package Versions

PackageVersion
<a href="https://github.com/jstedfast/MimeKit">MimeKit</a><a href="https://www.nuget.org/packages/MimeKit/3.0.0">3.0.0</a>
<a href="https://www.limilabs.com/mail">LimiLabs' Mail.dll</a><a href="https://www.nuget.org/packages/Mail.dll/3.0.21294.1630">3.0.21294.1630</a>
<a href="http://www.mime4.net/">Mime4Net</a><a href="https://www.nuget.org/packages/NI.Email.Mime/1.8.1">1.8.1</a>
<a href="https://github.com/andyedinborough/aenetmail">AE.Net.Mail</a><a href="https://www.nuget.org/packages/AE.Net.Mail/1.7.10">1.7.10</a>
<a href="https://github.com/pmengal/MailSystem.NET">MailSystem.NET</a><a href="https://www.nuget.org/packages/MailSystem.NET/2.0.1">2.0.1</a>
<a href="https://github.com/foens/hpop">OpenPOP.NET</a><a href="https://www.nuget.org/packages/OpenPop.NET/2.0.6.1120">2.0.6.1120</a>

Runtime

Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
  [Host]     : .NET Framework 4.8 (4.8.4420.0), X64 RyuJIT
  DefaultJob : .NET Framework 4.8 (4.8.4420.0), X64 RyuJIT

Results

HeavyHeaderEmailBenchmark

In this benchmark, each library is used to parse an in-memory email message that is almost all headers 1,000 times.

MethodMeanErrorStdDev
MimeKit30.22 ms0.207 ms0.183 ms
MimeKitPersistent30.08 ms0.311 ms0.276 ms
LimiLabs629.92 ms3.252 ms2.883 ms
Mime4Net517.56 ms3.442 ms3.051 ms
OpenPOP353.23 ms4.355 ms4.074 ms
AENetMail2,862.46 ms17.677 ms16.535 ms
MailSystemNET1,911.98 ms11.197 ms10.474 ms

JwzMboxBenchmark

In this benchmark, each library is used to parse the jwz.mbox Unix mbox spool from disk 10 times.

MethodMeanErrorStdDev
MimeKit171.3 ms0.87 ms0.77 ms
MimeKitPersistent160.1 ms1.50 ms1.33 ms
LimiLabs1,148.3 ms8.28 ms7.75 ms

StarTrekEmailBenchmark

In this benchmark, each library is used to parse startrek.eml from disk 1,000 times.

MethodMeanErrorStdDev
MimeKit218.6 ms1.95 ms1.73 ms
MimeKitPersistent205.5 ms1.72 ms1.61 ms
LimiLabs2,318.0 ms12.37 ms10.96 ms
Mime4Net10,726.6 ms38.19 ms35.73 ms
OpenPOPNANANA
AENetMail3,897.4 ms74.18 ms69.39 ms
MailSystemNET8,928.0 ms29.92 ms26.53 ms

Notes:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Media Type must be in the format type "/" subtype
Parameter name: mediaType
   at OpenPop.Mime.Header.HeaderFieldParser.cleanMediaType(String mediaType)
   at OpenPop.Mime.Header.HeaderFieldParser.ParseContentType(String headerValue)
   at OpenPop.Mime.Header.MessageHeader.ParseHeader(String headerName, String headerValue)
   at OpenPop.Mime.Header.MessageHeader.ParseHeaders(NameValueCollection headers)
   at OpenPop.Mime.Header.HeaderExtractor.ExtractHeadersAndBody(Byte[] fullRawMessage, MessageHeader& headers, Byte[]& body, IParsingErrorHandler parsingErrorHandler)
   at OpenPop.Mime.MessagePart.ParseMultiPartBody(Byte[] rawBody)
   at OpenPop.Mime.MessagePart.ParseMultiPartBody(Byte[] rawBody)
   at OpenPop.Mime.Message.Load(Stream messageStream, IParsingErrorHandler parsingErrorHandler)
   at Benchmarks.StarTrekEmailBenchmarks.OpenPOP()
   at BenchmarkDotNet.Autogenerated.Runnable_14.WorkloadActionNoUnroll(Int64 invokeCount)
   at BenchmarkDotNet.Engines.Engine.RunIteration(IterationData data)
   at BenchmarkDotNet.Engines.EngineFactory.Jit(Engine engine, Int32 jitIndex, Int32 invokeCount, Int32 unrollFactor)
   at BenchmarkDotNet.Engines.EngineFactory.CreateReadyToRun(EngineParameters engineParameters)
   at BenchmarkDotNet.Autogenerated.Runnable_14.Run(IHost host, String benchmarkName)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at BenchmarkDotNet.Autogenerated.UniqueProgramName.AfterAssemblyLoadingAttached(String[] args)

Xamarin3EmailBenchmark

In this benchmark, each library is used to parse xamarin3.eml from disk 1,000 times.

MethodMeanErrorStdDev
MimeKit1.629 s0.0168 s0.0157 s
MimeKitPersistent1.344 s0.0086 s0.0080 s
LimiLabs12.503 s0.0421 s0.0394 s
Mime4Net85.075 s0.4774 s0.3987 s
OpenPOP80.162 s0.6835 s0.6059 s
AENetMail30.925 s0.2161 s0.1915 s
MailSystemNET48.179 s0.6107 s0.5713 s

Notes:

Conclusions

Yea. No contest. MimeKit mops the floor with all of the other parsers out there.

How does your MIME parser compare?