[Mono-osx] Fast .NET<-->objc bridge. How to contribute?

Grishul Eugeny gesman at nm.ru
Mon Oct 20 02:02:14 EDT 2008



Geoff Norton-2 wrote:
> 
> Grishul Eugeny,
> 
>   Send me a copy of what you're working on and we can see how to proceed
> going forward.
> 
> -g
> 
> On Mon, 2008-10-06 at 07:45 -0700, Grishul Eugeny wrote:
>> Currently I'm working on fast, low-overhead objc<-->.NET bridge with
>> intensive codegeneration ( objc-reflection + .h files parsing ) opposed
>> to
>> hand-written monoobjc. Cocoa# project has a bad structure, have more
>> perfomance and memory overhead, all objc-wrapped classes are hand-written
>> and it can't catch objc exceptions. To resolve these issues I want to
>> cotribute my code to mono ( and replace Cocoa# entirely in future ). How
>> can
>> I do that?
> 
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
> 
> 

Mono profiler ( mono --profile:alloc ) seems to be broken on OSX, so
currently I can only measure perfomance of 3 libs:

ObjcMapper results:
00:00:00.5777030
00:00:00.5773450
00:00:00.5813300

Cocoa# results:
00:00:04.8446500
00:00:05.0754480
00:00:05.1001370

monobjc results:
00:00:05.3245100
00:00:05.3639260
00:00:05.3273440

My code is about x10 faster and x10 easer to maintain =) Also I have some
ideas for future perfomance improvents. What about integration to mono?

Sources:
// Cocoa#
namespace Cocoa
{
	public static class Program
	{
		static void Main( string[] args )
		{
			var pool = new AutoreleasePool();

			DoWork( 1 );

			var stopwatch = new Stopwatch();
			stopwatch.Start();

			DoWork( 20000 );
			stopwatch.Stop();
			System.Console.WriteLine( stopwatch.Elapsed );
		}

		static void DoWork( int iterations )
		{
			for( int i = 0; i < iterations; i++ )
			{
				var objcstring = new Cocoa.String( "some string to test" );
				objcstring.GetHashCode();

				new Cocoa.String( ( IntPtr ) ObjCMessaging.objc_msgSend(
objcstring.NativeObject, "stringByAppendingString:", typeof( IntPtr ),
typeof( IntPtr ), new Cocoa.String( "something" ).NativeObject )
).ToString();
			}
		}
	}
}

//Monobjc
namespace Monobjc.Cocoa
{
	public static class Program
	{
		static void Main( string[] args )
		{
			ObjectiveCRuntime.LoadFramework( "Cocoa" );
			ObjectiveCRuntime.Initialize(); 
			
			var pool = new NSAutoreleasePool();
			//pool.Init();

			DoWork( 1 );

			var stopwatch = new Stopwatch();
			stopwatch.Start();

			DoWork( 20000 );
			stopwatch.Stop();
			System.Console.WriteLine( stopwatch.Elapsed );
		}

		static void DoWork( int iterations )
		{
			for( int i = 0; i < iterations; i++ )
			{
				var objcstring = new NSString( "some string to test" );
				objcstring.GetHashCode();
				objcstring.StringByAppendingString( "something" ).ToString();
			}
		}
	}
}

//ObjcMapper
namespace ObjcMapper
{
	public static class Program
	{
		static void Main( string[] args )
		{
			using( var scope = new AutoreleaseScope() )
			{
				DoWork( 1 );

				var stopwatch = new Stopwatch();
				stopwatch.Start();

				DoWork( 20000 );
				stopwatch.Stop();
				System.Console.WriteLine( stopwatch.Elapsed );
			}
		}

		static void DoWork( int iterations )
		{
			for( int i = 0; i < iterations; i++ )
			{
				var objcstring = NSString.stringWithString_( "some string to test" );
				objcstring.GetHashCode();
				objcstring.stringByAppendingString_( "something" );
			}
		}
	}
}
-- 
View this message in context: http://www.nabble.com/Fast-.NET%3C--%3Eobjc-bridge.-How-to-contribute--tp19839363p20063661.html
Sent from the Mono - OSX mailing list archive at Nabble.com.



More information about the Mono-osx mailing list