← Back to team overview

kicad-developers team mailing list archive

Re: wxDC & wxGraphicsContext Test [2 Attachments]

 

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