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

Rafael Teixeira monoman at gmail.com
Thu May 12 13:50:08 EDT 2005


Also, you can create that font only once (cache it by the Name and
Size) and reuse in many pages, just beware o memory consumption, if
you doesn't limit the choices for fonts and sizes.

I also reiterate what Ben said, doesn't calculate things on the
server, because things will go diferently on the client. To add
another issue (besides user-chosen-css, installed fonts) the
resolution may be different, what makes the same font render quite
differently.

HIH,

On 5/12/05, Ben Maurer <bmaurer at ximian.com> wrote:
> 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
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 


-- 
Rafael "Monoman" Teixeira
---------------------------------------
I'm trying to become a "Rosh Gadol" before my own eyes. 
See http://www.joelonsoftware.com/items/2004/12/06.html for enlightment.
It hurts!



More information about the Mono-devel-list mailing list