kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #04253
Re: wxDC & wxGraphicsContext Test [2 Attachments]
-
To:
kicad-devel@xxxxxxxxxxxxxxx
-
From:
Dick Hollenbeck <dick@...>
-
Date:
Wed, 17 Feb 2010 08:46:44 -0600
-
In-reply-to:
<F435F8FF-0D20-49A4-9223-1B6539645342@...>
-
Scanners:
none
-
User-agent:
Thunderbird 2.0.0.23 (X11/20090817)
Marco Serantoni wrote:
As was requested, i've done a trivial benchmark, i've taken a file from wxWin tracker and readapted to do a trivial test just to begin to taste the difference of times of the two approaches.
The test does 100000 lines in a square of 100x100.
For the wxGC
wxGraphicsContext?
i've add 10 graphicspaths to begin to mimic which is a CAD usage.
This is a preliminary test, there is LARGE room for improvement.
This test requires a full version of Boost library.
--
Marco
Thank you.
What platform are these results on?
We know that wxDC sits on top of wxGraphicsContext on a MAC, so we'd
expect wxDC to be slower on a MAC since: 1) it is a longer code path and
2) does not combine line and move primitives for a common ->DrawPath().
Just curious about:
wxGraphicsContext & inner( *context );
It is unneeded, and is purely an alias for context.
boost::scoped_ptr< wxGraphicsContext >
Would not be the best wrapper for a "wxGraphicsContext*" if we were
going to use a construct like this everywhere.
Here is an alternative that would read far better.
class GC
{
wxGraphicsContext* ctx;
public:
GC( wxDC* )
{
// set ctx here by creating getting a wxGraphicsContext from wxDC
// (exercise for reader)
}
~GC()
{
// I assume this is needed:
delete ctx;
}
// inlined for speed equivalence
wxGraphicsContext* operator ->()
{
return ctx;
}
}
When the object goes out of scope the destructor is called automatically.
{
wxDC dc;
GC gc( dc )
:
gc->DrawPath()
// destructor called here.
}
The wxDC could possibly also be put in GC too, to hide its ugly existence.
If GC to hold and hide wxDC:
{
GC gc()
:
gc->DrawPath();
// GC destructor called here automatically
}
It would be nice to have some tests like this on other platforms. I
can do Linux in the next couple of weeks.
The Windows platform could be tested for both gdi+ and cairo.
We need to double check that none of the lines in the test are being
drawn on top of each other. I think would give dramatically different
results.
Dick
Follow ups
References