mono/xwt — pull request #99 by lytico (2012-04-06 21:35:12+00:00)
Title: Wpf.DrawingContext: improved memory consumption and performance

added DrawingPerformance-Expample
refactored Wpf.DrawingContext to reuse and lazy use of expensive System.Drawing-objects like pen, brush, font

results in short:
around 20% faster
SetColor needs 90 bytes instead of 14,673,402 bytes
Save needs 83,248 instead of 305,184 bytes

results in detail:
this pull request:
DrawingPerformance:
Time in sec 4,68 Frames per sec 258,49 Frames 1210
PerformanceAnalysis (Visual Studio 2010)
Function	Exclusive Samplings	Ecklusive Samplings in %
System.Drawing.Graphics.DrawPath(class System.Drawing.Pen,class System.Drawing.Drawing2D.GraphicsPath)	403	66.83
System.Drawing.Drawing2D.GraphicsPath.AddLine(float32,float32,float32,float32)	27	4.48
MemoryAnalysis (Visual Studio 2010)
Function	Inklusive Bytes	Exklusive Bytes
Xwt.WPFBackend.ContextBackendHandler.LineTo(object,float64,float64)	6,528	0
Xwt.WPFBackend.ContextBackendHandler.Save(object)	83,248	0
Xwt.WPFBackend.ContextBackendHandler.SetColor(object,valuetype Xwt.Drawing.Color)	90	0
Xwt.WPFBackend.ContextBackendHandler.Stroke(object)	14,688	0
Xwt.WPFBackend.DrawingContext..ctor(class System.Drawing.Graphics)	14,712	0
Xwt.WPFBackend.DrawingContext..ctor(class Xwt.WPFBackend.DrawingContext)	34,272	0
Xwt.WPFBackend.DrawingContext.CopyTo(class Xwt.WPFBackend.DrawingContext,bool)	34,272	0
Xwt.WPFBackend.DrawingContext.get_Path()	6,528	6,528
Xwt.WPFBackend.DrawingContext.get_Pen()	14,688	14,688
Xwt.WPFBackend.DrawingContext.Save()	83,248	35,904

Branch Mono/Master (https://github.com/mono/xwt/commit/3244d309c0437384ff79e0b9885b4da3b173d48a)
DrawingPerformance:
Time in sec 5,66 Frames per sec 213,71 Frames 1210
PerformanceAnalysis (Visual Studio 2010)
Function	Exclusive Samplings	Exclusive Samplings in %
System.Drawing.Graphics.DrawPath(class System.Drawing.Pen,class System.Drawing.Drawing2D.GraphicsPath)	418	62.86
System.Drawing.SolidBrush..ctor(valuetype System.Drawing.Color)	40	6.02
System.Drawing.Drawing2D.GraphicsPath.AddLine(float32,float32,float32,float32)	16	2.41
MemoryAnalysis (Visual Studio 2010)
Function	Exclusive Bytes	Inclusive Bytes
Xwt.WPFBackend.ContextBackendHandler.Save(object)	0	314,992
Xwt.WPFBackend.ContextBackendHandler.SetColor(object,valuetype Xwt.Drawing.Color)	0	14,673,402
Xwt.WPFBackend.DrawingContext..ctor(class System.Drawing.Graphics)	14,688	14,688
Xwt.WPFBackend.DrawingContext..ctor(class System.Drawing.Graphics)	14,688	17,190
Xwt.WPFBackend.DrawingContext..ctor(class System.Drawing.Graphics)	6,528	6,528
Xwt.WPFBackend.DrawingContext..ctor(class System.Drawing.Graphics)	17,952	91,392
Xwt.WPFBackend.DrawingContext..ctor(class System.Drawing.Graphics)	0	4,896
Xwt.WPFBackend.DrawingContext..ctor(class System.Drawing.Graphics)	0	4,896
Xwt.WPFBackend.DrawingContext..ctor(class Xwt.WPFBackend.DrawingContext)	14,688	14,688
Xwt.WPFBackend.DrawingContext..ctor(class Xwt.WPFBackend.DrawingContext)	14,688	35,904
Xwt.WPFBackend.DrawingContext..ctor(class Xwt.WPFBackend.DrawingContext)	17,952	91,392
Xwt.WPFBackend.DrawingContext..ctor(class Xwt.WPFBackend.DrawingContext)	0	6,528
Xwt.WPFBackend.DrawingContext..ctor(class Xwt.WPFBackend.DrawingContext)	0	14,688
Xwt.WPFBackend.DrawingContext..ctor(class Xwt.WPFBackend.DrawingContext)	14,688	14,688
Xwt.WPFBackend.DrawingContext..ctor(class Xwt.WPFBackend.DrawingContext)	6,528	6,528
Xwt.WPFBackend.DrawingContext..ctor(class Xwt.WPFBackend.DrawingContext)	0	6,528
Xwt.WPFBackend.DrawingContext..ctor(class Xwt.WPFBackend.DrawingContext)	17,952	83,232
Xwt.WPFBackend.DrawingContext.Save()	9,792	9,808
Xwt.WPFBackend.DrawingContext.Save()	17,952	305,184
Xwt.WPFBackend.DrawingContext.SetColor(valuetype System.Drawing.Color)	14,673,312	14,673,312