public void TestParsePerformance() { string fix = GenRandomFIXString(); HiPerfTimer timer = new HiPerfTimer(); timer.Start(); const int numMsgs = 50000; for (int i = 0; i < numMsgs; i++) { Message m = new Message(); MakeMessage(m, fix); } timer.Stop(); Console.WriteLine("Total per second: " + ((1 / timer.Duration) * numMsgs).ToString()); // Test message creation latency. timer.Start(); Message newMsg = new Message(); MakeMessage(newMsg, fix); timer.Stop(); Console.WriteLine( String.Format("Latency for parsing one FIX message in microseconds: {0}", (timer.Duration * 1000000).ToString())); }
public void TestStructVsClass() { HiPerfTimer timer = new HiPerfTimer(); const int num = 1000000; timer.Start(); List <MyClass> classes = new List <MyClass>(num); for (int i = 0; i < num; i++) { classes.Add(new MyClass(i)); } timer.Stop(); Console.WriteLine("Constructing {0} classes: {1}", num, timer.Duration.ToString()); timer.Start(); List <MyStruct> structs = new List <MyStruct>(num); for (int i = 0; i < num; i++) { structs.Add(new MyStruct(i)); } timer.Stop(); Console.WriteLine("Constructing {0} structs: {1}", num, timer.Duration.ToString()); timer.Start(); MyClassWithSmallClasses test1 = new MyClassWithSmallClasses(num); timer.Stop(); Console.WriteLine("Duration to construct large class containing smaller classes: " + timer.Duration.ToString()); timer.Start(); MyClassWithSmallStructs test2 = new MyClassWithSmallStructs(num); timer.Stop(); Console.WriteLine("Duration to construct large class containing smaller structs: " + timer.Duration.ToString()); }
public void TestUTFByteEncoding() { string test = "LKDSAJFLAKJSFLKJFLAKSJFLAKSJFASLFASDJLFLKASFLKAFSJLKALKFSKJASLFLAFSJKLKJAFSLAALKSFKJLSAFLJKFSALJKAFSLJKAFSJKLAFSKJLFSAKJLFASKLJAFSKJLAFSLJKAFSKJLFSKJLFSALJKFSAJKLAFSLJKAFSJKLFSJKKJLAFS"; const int numIterations = 50000; HiPerfTimer timer = new HiPerfTimer(); timer.Start(); for (int i = 0; i < numIterations; i++) { byte[] utf8 = Encoding.UTF8.GetBytes(test); } timer.Stop(); Console.WriteLine("Total UTF8 per second for " + test.Length + "-character strings: " + ((1 / timer.Duration) * numIterations).ToString()); timer.Start(); for (int i = 0; i < numIterations; i++) { byte[] utf16 = Encoding.Unicode.GetBytes(test); } timer.Stop(); Console.WriteLine("Total UTF16 per second for " + test.Length + "-character strings: " + ((1 / timer.Duration) * numIterations).ToString()); }
public void TestNewParser() { HiPerfTimer timer = new HiPerfTimer(); string fix = GenRandomFIXString(); const int times = 50000; timer.Start(); for (int i = 0; i < times; i++) { Message m = new Message(); m.FromString(fix); } timer.Stop(); Console.WriteLine("Total per second [new parser]: " + ((1 / timer.Duration) * times).ToString()); }
public void TestStructVsClass() { HiPerfTimer timer = new HiPerfTimer(); const int num = 1000000; timer.Start(); List<MyClass> classes = new List<MyClass>(num); for (int i = 0; i < num; i++) classes.Add(new MyClass(i)); timer.Stop(); Console.WriteLine("Constructing {0} classes: {1}", num, timer.Duration.ToString()); timer.Start(); List<MyStruct> structs = new List<MyStruct>(num); for (int i = 0; i < num; i++) structs.Add(new MyStruct(i)); timer.Stop(); Console.WriteLine("Constructing {0} structs: {1}", num, timer.Duration.ToString()); timer.Start(); MyClassWithSmallClasses test1 = new MyClassWithSmallClasses(num); timer.Stop(); Console.WriteLine("Duration to construct large class containing smaller classes: " + timer.Duration.ToString()); timer.Start(); MyClassWithSmallStructs test2 = new MyClassWithSmallStructs(num); timer.Stop(); Console.WriteLine("Duration to construct large class containing smaller structs: " + timer.Duration.ToString()); }