public static string EncodeUsingQuotedPrintableEncoderStream(string text) { var mem = new MemoryStream(); var quotedPrintableEncoderStream = new QuotedPrintableEncoderStream(mem); quotedPrintableEncoderStream.Write(text); return TestHelpers.ReadMemoryStreamIntoString(mem); }
public void PerformanceTest() { var buf = new byte[1 * 1024 * 1024]; for (var i = 0; i < buf.Length; i++) buf[i] = (byte)i; using (var mem = new MemoryStream(3 * buf.Length)) using (var encoder = new QuotedPrintableEncoderStream(mem)) { var stopwatch = Stopwatch.StartNew(); encoder.Write(buf, 0, buf.Length); var elapsedMilliseconds = stopwatch.ElapsedMilliseconds; var message = String.Format( "Encoded {0} bytes in {1} ms ({2} MB/s)", buf.Length, elapsedMilliseconds, ((double) buf.Length*1000/1024/1024/stopwatch.ElapsedMilliseconds).ToString("F2") ); Assert.True(false, message); } }