title: Very slow operation of Epplus Save(), SaveAs(), etc. methods when debugging
body: <p>Environment - Windows 10, Visual Studio 2017, netcore2.0, Debug build.</p>
  
  <p>When saving an Excel file using Epplus 4.1.1 while debugging, the save operation takes a much longer amount of time than I would expect. </p>
  
  <p>Here's some timing when ran with Debug -> Start Debugging</p>
  
  <pre><code>Saving 100 rows in 2065ms.
  Saving 200 rows in 2050ms.
  Saving 400 rows in 4003ms.
  Saving 800 rows in 11360ms.
  Saving 1600 rows in 18377ms.
  Saving 3200 rows in 34139ms.
  </code></pre>
  
  <p>And the same when ran with Debug -> Start Without Debugging</p>
  
  <pre><code>Saving 100 rows in 401ms.
  Saving 200 rows in 49ms.
  Saving 400 rows in 28ms.
  Saving 800 rows in 58ms.
  Saving 1600 rows in 94ms.
  Saving 3200 rows in 198ms.
  </code></pre>
  
  <p>When targeting .NET Framework 4.6.1, results while debugging are vastly better - </p>
  
  <pre><code>Saving 100 rows in 215ms.
  Saving 200 rows in 26ms.
  Saving 400 rows in 42ms.
  Saving 800 rows in 78ms.
  Saving 1600 rows in 146ms.
  Saving 3200 rows in 279ms.
  </code></pre>
  
  <p>I obviously know that debugging is molasses slow, but this is a miniscule amount of data. Is there anything I can do to poke this along to go faster when debugging targeting .NET Core 2.0?</p>
  
  <p>--</p>
  
  <p>Here is the program that produced the above output - </p>
  
  <pre><code>namespace ConsoleApp9
  {
      using System;
      using System.Collections.Generic;
      using System.IO;
      using System.Text;
      using System.Linq;
      using System.Diagnostics;
  
      using OfficeOpenXml;
  
      public class Foo
      {
          public string Name { get; set; }
          public int Number { get; set; }
          public char? Character { get; set; }
      }
  
      class Program
      {
          static void Main(string[] args)
          {
              Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
  
              IEnumerable&lt;Foo&gt; RandomFoo()
              {
                  var random = new Random();
                  const string chars = "ABCDEFGHIJKLH";
                  while (true)
                  {
                      yield return new Foo
                      {
                          Character = random.NextDouble() &lt; .1 ? null : (char?) 'A',
                          Number = random.Next(0, 10),
                          Name = new string(Enumerable.Repeat(chars, 8)
                              .Select(x =&gt; x[random.Next(x.Length)])
                              .ToArray()
                          )
                      };
                  }
              }
  
              for (var i = 100; i &lt;= 1000000; i *= 2)
              {
                  var sw = Stopwatch.StartNew();
  
                  var stream = new MemoryStream();
                  using (var package = new ExcelPackage(stream))
                  {
                      var sheet = package.Workbook.Worksheets.Add("Sheet");
                      var foos = RandomFoo().Take(i);
                      sheet.Cells["A1"].LoadFromCollection(foos);
  
                      package.Save(); // very long operation here
                      stream.Seek(0, SeekOrigin.Begin);
                  }
  
                  var file = new FileInfo("test.xlsx");
                  using (var fileStream = file.Create())
                  {
                      stream.CopyTo(fileStream);
                  }
  
                  Console.WriteLine($"Saving {i} rows in {sw.ElapsedMilliseconds}ms.");
              }
          }
      }
  }
  </code></pre>