[Mono-devel-list] Mono ASP.NET is very slow with big html pages...

Ben Maurer bmaurer at ximian.com
Thu May 12 11:03:00 EDT 2005


On Thu, 2005-05-12 at 11:04 +0200, Hubert FONGARNAND wrote:
> I apologize, i've found my problem...
> This slowdown is due to System.Drawing 
> 
> Let me explain...
> Mono renders a page with more than 100 menu, for each menu, the largest item 
> size is calculated by this function :
> 
> 		  SizeF size;
>                   float emSize = Convert.ToSingle(fontInfo.Size.Unit.Value);
>                   emSize = (emSize==0 ?8 :emSize);   
>                   Font stringFont = new Font(fontInfo.Name, emSize); 
>                   Graphics g=new Bitmap(1,1);
>                   size = g.MeasureString(text, stringFont);                  
> 		  g.Dispose();
>                   return size;     
> 
> After doing some tests, i've seen that the slowest line is : 
>                   Font stringFont = new Font(fontInfo.Name, emSize); 
> So the creation of this Font object (the font is Arial) is extremely slow 
> comparing to MS.NET...
> If I remove this line, the page loads as fast as MS.NET (a little bit 
> faster...)
> 
> Is there a way to optimize System.Drawing for this problem;
> or is there a better way to measure a text string length (with variable font 
> size) without using this very slow function...

I'm not sure how much we can speed that up. I can take a look at how
Cairo does the stuff.

However, if I understand what you are doing correctly, you are trying to
measure a string on the server and see how large it will be on the
client. I am not sure how well that will work. On the client side,
people might have different fonts installed, or might even use a user
css sheet. Nonetheless, we should still try to be faster here.

-- Ben




More information about the Mono-devel-list mailing list