Click here to Skip to main content
15,885,278 members
Articles / Desktop Programming / WPF

Benchmark start-up and system performance for .Net, Mono, Java, C++ and their respective UI

Rate me:
Please Sign up or sign in to vote.
4.94/5 (44 votes)
2 Sep 2010CPOL19 min read 159.3K   1.3K   67  
What is the start-up and system performance overhead for .Net, Mono, Java versus C++ and Forms, WPF, Swing versus MFC
using System;
using System.Runtime.InteropServices;

namespace DotNet11Perf
{
	//see http://msdn.microsoft.com/en-us/library/9w519wzk.aspx for runtime selection
	class Program
	{
    /*   
#if DEBUG

        /// Return Type: HANDLE->void*
        [DllImport("kernel32.dll", EntryPoint = "GetCurrentProcess")]
        private static extern IntPtr GetCurrentProcess();
        [DllImport("kernel32.dll", EntryPoint = "GetProcessTimes")]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool GetProcessTimes([In] System.IntPtr hProcess, [Out] out long CreationTime, [Out] out long ExitTime, [Out] out long KernelTime, [Out] out long UserTime);
#endif
      */   
		private const long TicksPerMiliSecond = TimeSpan.TicksPerSecond / 1000;
		static int Main(string[] args)
		{
			DateTime mainEntryTime = DateTime.UtcNow;
			int result = 0;

			if (args.Length > 0)
			{
				DateTime launchTime = System.DateTime.FromFileTimeUtc(long.Parse(args[0]));
				long diff = (mainEntryTime.Ticks - launchTime.Ticks) / TicksPerMiliSecond;
				/*
#if DEBUG
                const long StartOfEpochTicks = 504911232000000000;
                Console.WriteLine("Launch time is    {0} ticks", launchTime.Ticks - StartOfEpochTicks);
                long CreationTime ,ExitTime,KernelTime,UserTime;
                if (GetProcessTimes(GetCurrentProcess(), out CreationTime, out ExitTime, out KernelTime, out UserTime))
                {
                    Console.WriteLine("Creation time is  {0} ticks, adds {1}", CreationTime, CreationTime - long.Parse(args[0]));
                    Console.WriteLine("Main EntryTime is {0} ticks, adds {1}", mainEntryTime.Ticks - StartOfEpochTicks, mainEntryTime.Ticks- System.DateTime.FromFileTimeUtc(CreationTime).Ticks);
                }
                Console.WriteLine("Started in {0} ms",diff);



#endif
*/
				result = (int)diff;

			}
			else
			{
				System.GC.Collect(2);
				System.GC.WaitForPendingFinalizers();
				System.Threading.Thread.Sleep(5000);
			}

			return result;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Decebal Mihailescu is a software engineer with interest in .Net, C# and C++.

Comments and Discussions