Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added benchmark

  • Loading branch information...
commit 8d4350cc3c25119f9e54004a2ab9563882452018 1 parent b2e2ea0
@DerekLiang authored
Showing with 29 additions and 1 deletion.
  1. +29 −1 Simplicit.Net.Lzo.UnitTest/Program.cs
View
30 Simplicit.Net.Lzo.UnitTest/Program.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Diagnostics;
namespace Simplicit.Net.Lzo.UnitTest
{
@@ -21,14 +22,41 @@ static void Main(string[] args)
string str = sb.ToString();
Console.WriteLine("Original-Length: " + str.Length);
+ byte[] data = Encoding.Default.GetBytes(str);
+
// Now compress the 70000 byte string to something much smaller
- byte[] compressed = lzo.Compress(Encoding.Default.GetBytes(str));
+ byte[] compressed = lzo.Compress(data);
Console.WriteLine("Compressed-Length: " + compressed.Length);
// Decompress the string to its original content
string str2 = Encoding.Default.GetString(lzo.Decompress(compressed));
Console.WriteLine("Decompressed-Length: " + str2.Length);
Console.WriteLine("Equality: " + str.Equals(str2));
+
+ Console.WriteLine("benchmark...");
+ Stopwatch stopWatch = new Stopwatch();
+ int count = 0;
+ stopWatch.Start();
+ while (stopWatch.ElapsedMilliseconds < 2000)
+ {
+ lzo.Compress(data);
+ count++;
+ }
+ stopWatch.Stop();
+ Console.WriteLine("Compression throughput is (KByte/sec): " + data.Length * count / stopWatch.ElapsedMilliseconds);
+
+ count = 0;
+ stopWatch.Reset();
+ stopWatch.Start();
+ while (stopWatch.ElapsedMilliseconds < 2000)
+ {
+ lzo.Decompress(compressed);
+ count++;
+ }
+ stopWatch.Stop();
+ Console.WriteLine("Uncompression throughput is (KByte/sec): " + data.Length * count / stopWatch.ElapsedMilliseconds);
+
+ Console.ReadKey();
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.