Test your plugin's load time

Discussion in 'Resources' started by RROD, Feb 3, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    RROD

    You want to know how to test the time it takes to load and unload your plugin?

    Well here's a neat way to do it:

    Code:Java
    1.  
    2. public class MyPlugin extends JavaPlugin {
    3.  
    4. private Logger log;
    5. private long loadTime;
    6.  
    7. @Override
    8. public void onEnable() {
    9. startTest();
    10. // Do a ton of stuff.
    11. stopTest();
    12. }
    13.  
    14. public void startTest() {
    15. loadTime = System.currentTimeMillis();
    16. }
    17.  
    18. public void stopTest() {
    19. loadTime = System.currentTimeMillis() - loadTime;
    20. this.getLogger().info("Load Time: <" + loadTime + "ms> ");
    21. }
    22. }


    How does it work?
    1. The startTest() method gets the system time (ms) at the start of the test, and stores it into the variable loadTime.
    2. When stopTest() is called, the initial clock time is subtracted from the current time - leaving the difference.
    3. The difference is printed to console
     
  2. Offline

    hammale

    kool idea :D
     
  3. Thanks, I we have added this to CommandsEx, will give credits when it is updated.
     
    CarlosArias604 likes this.
Thread Status:
Not open for further replies.

Share This Page