[Mono-dev] substantial performance regression between 2.10 and 2.6 or impl diff?

Jonathan Shore jonathan.shore at gmail.com
Sat Aug 27 14:52:57 EDT 2011


I guess the code was trimmed off in the mailer (I sent in the initial note).  Here it is inlined as text:


using System;

namespace TestHeap
{
	
	public interface IDatum
	{
		long		Timestamp		{  get; }
	}
	
	
	public struct SDelta : IDatum
	{
		public SDelta (long timestamp, long id, double size, double price, double maxsize = 0)
		{
			_timestamp = timestamp;
			_id = id;
			_size = size;
			_price = price;
			_maxsize = maxsize;
		}
		
		
		// Properties
		
		
		public long Timestamp
			{  get { return _timestamp; } }
		
		public long Id
			{  get { return _id; } }
		
		public double Size 
			{  get { return _size; } }
		
		public double Price
			{  get { return _price; } }
		
		public double MaxSize
			{  get { return _maxsize; } }
		
		
		// Variables
		
		private long	_timestamp;
		private long	_id;
		private double	_size;
		private double	_price;
		private double	_maxsize;
	}
	
	
	public class CDelta : IDatum
	{
		public CDelta (long timestamp, long id, double size, double price, double maxsize = 0)
		{
			_timestamp = timestamp;
			_id = id;
			_size = size;
			_price = price;
			_maxsize = maxsize;
		}
		
		
		// Properties
		
		
		public long Timestamp
			{  get { return _timestamp; } }
		
		public long Id
			{  get { return _id; } }
		
		public double Size 
			{  get { return _size; } }
		
		public double Price
			{  get { return _price; } }
		
		public double MaxSize
			{  get { return _maxsize; } }
		
		
		// Variables
		
		private long	_timestamp;
		private long	_id;
		private double	_size;
		private double	_price;
		private double	_maxsize;
	}

	class MainClass
	{
		private static SDelta f (int i)
		{
			return new SDelta (i*1000, i, 1e6, 1.400 + i / 1000);
		}

		private static CDelta g (int i)
		{
			return new CDelta (i*1000, i, 1e6, 1.400 + i / 1000);
		}

		
		public static void Main (string[] args)
		{
			Console.WriteLine ("Running benchmark");

			// struct test
			long Tnow1 = DateTime.Now.Ticks;
	
			double sum1 = 0;
			for (int i = 0 ; i < 100000000 ; i++)
				sum1 += f(i).Price;

			long Tend1 = DateTime.Now.Ticks;

			// class test
			long Tnow2 = DateTime.Now.Ticks;
	
			double sum2 = 0;
			for (int i = 0 ; i < 100000000 ; i++)
				sum2 += g(i).Price;

			long Tend2 = DateTime.Now.Ticks;

			
			Console.WriteLine ("struct sum: " + sum1 + ", time: " + ((Tend1 - Tnow1) / 1e7) + " secs");
			Console.WriteLine ("class sum: " + sum2 + ", time: " + ((Tend2 - Tnow2) / 1e7) + " secs");
		}
	}
}


On Aug 27, 2011, at 2:34 PM, Bojan Rajkovic wrote:

> 
> On Aug 27, 2011, at 2:30 PM, Jonathan Shore wrote:
> 
>> 
>> On Aug 27, 2011, at 2:20 PM, Bojan Rajkovic wrote:
>> 
>>> On Aug 27, 2011, at 2:15 PM, Jonathan Shore wrote:
>>> 
>>>> 
>>>> My machine is an old 2006 Mac Pro 1,1  2 x Xeon 5130 (64 bit) running OSX lion.   Here are the respective versions of mono:
>> 
>> Would 32 vs 64 really make that much of a difference?   I have used 32 bit C applications without any noticable perf difference.    
>> 
>> I am worried that there may also be a problem with 2.10.x on other platforms.   It would put my mind at ease if this is just a OSX implementation issue.
>> 
>> I don't know if I can reasonably install both 2.6.x and 2.10.x on linux without hand compiling and doing some magic in config.    Would be nice to know that this "benchmark" performs the same or better from 2.6 to 2.10.
>> 
>> Jonathan
> 
> Might make a difference with respect to performance if your struct can fit in the registers on 64-bit, but cannot on 32-bit. :-) If you could post your benchmark code, more people could test.
> 
> —Bojan
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110827/1e8f3420/attachment-0001.html 


More information about the Mono-devel-list mailing list