public void BenchmarkSimpleWriter() { //var buffer = new byte[500000]; var memoryStream = new MemoryStream(buffer); var values = new Dictionary <string, string>(); values["Year"] = "2008"; values["Title"] = "Iron Man"; values["Production Studio"] = "Marvel Studios"; foreach (var iteration in Benchmark.Iterations) { using (var streamWriter = new StreamWriter(memoryStream, Encoding.Default, 512, true)) { using (iteration.StartMeasurement()) { var simpleWriter = new SimpleWriter(streamWriter); simpleWriter.WriteHeader("Year", "Title", "Production Studio"); for (int innerIteration = 0; innerIteration < Benchmark.InnerIterationCount; innerIteration++) { simpleWriter.WriteLine(values); } streamWriter.Flush(); } } memoryStream.Seek(0, SeekOrigin.Begin); } }
public void BenchmarkSimpleWriterToFile() { var values = new Dictionary <string, string>(); values["Year"] = "2008"; values["Title"] = "Iron Man"; values["Production Studio"] = "Marvel Studios"; int outerIterations = 0; foreach (var iteration in Benchmark.Iterations) { var fileStream = new FileStream($"tempfile{outerIterations++}.csv", FileMode.Create, FileAccess.Write); using (var streamWriter = new StreamWriter(fileStream, Encoding.Default, 512, false)) { using (iteration.StartMeasurement()) { var simpleWriter = new SimpleWriter(streamWriter); simpleWriter.WriteHeader("Year", "Title", "Production Studio"); for (int innerIteration = 0; innerIteration < Benchmark.InnerIterationCount; innerIteration++) { simpleWriter.WriteLine(values); } streamWriter.Flush(); } } } }
private void WriteMarvelCsv(SimpleWriter simpleWriter) { simpleWriter.WriteHeader("Year", "Title", "Production Studio"); var values = new Dictionary <string, string>() { { "Year", "2008" }, { "Title", "Iron Man" }, { "Production Studio", Marvel } }; simpleWriter.WriteLine(values); values["Title"] = "The Incredible Hulk"; simpleWriter.WriteLine(values); values["Title"] = "Punisher: War Zone"; simpleWriter.WriteLine(values); values["Year"] = "2009"; values["Title"] = "X-Men Origins: Wolverine"; values["Production Studio"] = Fox; simpleWriter.WriteLine(values); values["Year"] = "2010"; values["Title"] = "Iron Man 2"; values["Production Studio"] = Marvel; simpleWriter.WriteLine(values); values["Year"] = "2011"; values["Title"] = "Thor"; simpleWriter.WriteLine(values); values["Title"] = "X-Men: First Class"; values["Production Studio"] = Fox; simpleWriter.WriteLine(values); }