Bug 1819 - LockBits is slow on Linux
Summary: LockBits is slow on Linux
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Drawing ()
Version: 2.10.x
Hardware: PC Linux
: Low enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-11-02 06:58 UTC by adam.meszaros
Modified: 2011-11-09 23:10 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

test code (632 bytes, text/plain)
2011-11-02 06:58 UTC, adam.meszaros

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 1819 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description adam.meszaros 2011-11-02 06:58:33 UTC
Created attachment 805 [details]
test code

Description of Problem:
BitmapData Bitmap.LockBits is slower than .net 3.5 on windows.

Steps to reproduce the problem:
Compile the code and run it.

Actual Results:
With Mono on Linux, the test exe runs 4.9-5.0 seconds.
(Only lockbits: 4300 ms, only new bitmap+dispose: 600 ms)

Expected Results:
With .NET on Windows, runs 1 second.

How often does this happen? 

Additional Information:
 Ubuntu 11.10 x86, Mono 2.10.5-1
 Core2Duo E7500
Compile code: 
 mcs lockbits.cs -r:System.Drawing.dll (or gmcs...)
 mono lockbits.exe

The Code:
using System;
using System.Drawing;
using System.Drawing.Imaging;

namespace lockbitstestconsole
	class MainClass
		public static void Main (string[] args)
			DateTime start = DateTime.Now;
            for (int i = 0; i < 1000; i++)
                Bitmap b = new Bitmap(640, 480);
                BitmapData d = b.LockBits(new System.Drawing.Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadOnly, b.PixelFormat);
			string s = (DateTime.Now - start).TotalMilliseconds.ToString();
Comment 1 Miguel de Icaza [MSFT] 2011-11-09 23:10:55 UTC
If someone wants to look at this, the routine to profile and tune lives in libgdiplus: