RepeatingTasks Performance Help

Discussion in 'Plugin Development' started by Evonoucono, Oct 10, 2018.

  1. I have the need in my plugin to have 3 RepeatingTasks. One every 0.1 seconds, another every 1 second, and another every 10 seconds. I have no idea how efficient these tasks are so what would be better in terms of performance? Having 3 separate repeating tasks, or doing:
    Code:
            Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
               
                int count = 0;
                public void run() {
                   
                    if (count%10==0) {
                        everySecond();
                       
                        if (count%100==0) {
                            everyTenSeconds();
                           
                        }
                    }
                    count++;
                }
            }, 2, 2);
    Modulus calculations are slow, so I'd assume 3 repeating tasks would be better. Any other ideas?
     
  2. Offline

    timtower Ninja on the waves Moderator

    @Evonoucono Assuming you only have 1 of those: you won't notice the difference.
    3 tasks seem cleaner though.
     
  3. That's what I thought, thanks.
     

Share This Page