Skip to content
Adrian Papari edited this page Jul 22, 2014 · 11 revisions

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 VoidSystem extends VoidEntitySystem {
    public VoidSystem() {
        super();
    }
    
    @Override
    protected void processSystem() {
        // process system
    }
}

###What the JVM gets:

public class VoidSystem extends VoidEntitySystem {
    private Profiler $profiler;
    
    public VoidSystem()     {
        super();
    }
    
    @Override
    protected void initialize() {
        $profiler = new Profiler();
        $profiler.initialize(this, world);
    }
    
    @Override
    protected void begin() {
        $profiler.start();
    }
    
    @Override
    protected void end() {
        $profiler.stop();
    }
    
    @Override
    protected void processSystem() {
        // process system
    }
}
Clone this wiki locally