Created
September 13, 2017 05:57
-
-
Save gerrard00/1a2584adcc84163f4d8cc69e40022092 to your computer and use it in GitHub Desktop.
Xml Compression tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Xml; | |
namespace Test | |
{ | |
class Test | |
{ | |
static void Main() | |
{ | |
var stopWatch = new Stopwatch(); | |
stopWatch.Start(); | |
using(var inputStream = File.OpenRead(@"c:\junk\supp2017.xml")) | |
{ | |
var doc = new XmlDocument(); | |
doc.Load(inputStream); | |
} | |
stopWatch.Stop(); | |
Console.WriteLine("Loading xml {0}", stopWatch.Elapsed.TotalMilliseconds); | |
Console.WriteLine("Done"); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.IO; | |
using System.IO.Compression; | |
using System.Xml; | |
namespace Test | |
{ | |
class Test | |
{ | |
static void Main() | |
{ | |
var stopWatch = new Stopwatch(); | |
stopWatch.Start(); | |
using(var inputStream = File.OpenRead(@"c:\junk\supp2017.xml.cmp")) | |
{ | |
using (DeflateStream decompressingStream = new DeflateStream(inputStream, CompressionMode.Decompress)) | |
{ | |
var doc = new XmlDocument(); | |
doc.Load(decompressingStream); | |
} | |
} | |
stopWatch.Stop(); | |
Console.WriteLine("Loading xml {0}", stopWatch.Elapsed.TotalMilliseconds); | |
Console.WriteLine("Done"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You convinced me that
XmlDocument.Load()
is slow enough to be on par with the extremely slow disk I/O (especially for GB-sized documents), but still isn't slow enough to render compression worthless as you stated. So your reasoning is not completely wrong – I'm willing to remove the downvote from your answer. But this can be done only after editing it because 2+ days has elapsed. Thank you for the constructive discussion.