[mapguide-internals] Re: RFC110 Profiling API enhancement

Jackie Ng jumpinjackie at gmail.com
Wed Apr 27 21:39:24 EDT 2011


What about using the decorator pattern to create set of instrumented service
classes that wraps the respective service class to be profiled and provides
the same interface as the class being wrapped.

So something like:

class MgProfiledRenderingService : public MgRenderingService
{
private:
    MgRenderService* m_innerService; //The actual object to be profiled
    //Other internal state specific to profiling
    ...

public:
    MgByteReader* RenderMap(...);
    //Other MgRenderingService APIs
    ...

    //The actual profiling APIs
    MgProfileResult* ProfileRenderMap(...);
    ...
};

MgByteReader* MgProfiledRenderingService::RenderMap(...)
{
    Ptr<MgByteReader> result;
    //Start performance measuring here
    result = m_innerService->RenderMap(...);
    //End performance measuring here, and update internal profiling state
    return result.Detach();
}

MgProfileResult* MgProfiledRenderingService::ProfileRenderMap(...)
{
    Ptr<MgProfileResult> result;
    //Call the instrumented API(s)
    //collect the profiled result information and return it
    return result.Detach();
}

This way, the original code does not require any changes at all. Barring any
inheritance constraints, most (if not all) MapGuide classes could be
profiled in this fashion. These profiled classes need not be made public,
and could be just internal to this MgProfilingService.

- Jackie

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/RFC110-Profiling-API-enhancement-tp6296419p6311760.html
Sent from the MapGuide Internals mailing list archive at Nabble.com.


More information about the mapguide-internals mailing list