Skip to content
Adrian Papari edited this page Aug 3, 2013 · 1 revision

Profile EntitySystems with user-specified profiler class.

Injects conditional profiler call at start of begin() and before any exit point in end().

Minimal example

###What you type:

@Profile(using=Profiler.class, enabled=true)
public class TestSystem extends IntervalEntityProcessingSystem
{
    public TestSystem()
    {
        super(Aspect.getEmpty(), 0.05f);
    }
    
    @Override
    protected void process(Entity e)
    {
        // process system
    }
}

###What the JVM gets:

@WovenByTheHuntress // marker annotation; don't process class when present
@Profile(using=Profiler.class, enabled=true)
public class TestSystem extends IntervalEntityProcessingSystem
{
    private final Profiler $profiler;
    
    public TestSystem()
    {
        super(Aspect.getEmpty(), 0.05f);
        $profiler = new Profiler();
        $profiler.setTag(getClass());
    }
    
    @Override
    protected void begin()
    {
        $profiler.start();
    }
    
    @Override
    protected void end()
    {
        $profiler.stop();
    }
    
    @Override
    protected void process(Entity e)
    {
        // process system
    }
}
Clone this wiki locally