1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Using more event listeners

Discussion in 'Development' started by mal0ne_23, Jul 22, 2017.

  1. mal0ne_23

    mal0ne_23 Spider Jockey

    Messages:
    30
    GitHub:
    mal0ne-23
    My server's core plugin (plugin that manages most things on servers) uses a few event listeners in different areas, like one for anticheat, one for chat filter, etc.. I was wondering if more event listeners would make any noticeable difference in performance, or would it be the same as having one? I want to improve performance, but at the same time keep things organized.
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    More event listeners won't, but a lot (say around 50) would. Suppose all the 50 listeners listen to PlayerJoinEvent. PluginManager::callEvent() will have to loop through all the 50 methods, which would take at least the same time as executing a simple MySQL INSERT statement without optimizations. I've heard rumors that PHP 8 will have a new JIT engine, which could make loop execution time faster.
     
    Last edited: Jul 22, 2017
    jasonwynn10, Sandertv and mal0ne_23 like this.
  3. mal0ne_23

    mal0ne_23 Spider Jockey

    Messages:
    30
    GitHub:
    mal0ne-23
    Ahh, that makes sense. I use like 6 or something like that. And PHP8???!?!?! Yeah hopefully it's a lot fucking faster than PHP 7.
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    If PHP 8 has a JIT engine, typehints and strict types would actually speed up code execution. I don't think PHP 8 will already have this included though, but I might be wrong!
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Yeah, but googling "php jit" gives me a ton of PHP 8 rumors.
     
    Sandertv likes this.
  6. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    You guys give PHP 7 way too much shit. I invite you all to just remember PHP 5, and also to remember that there are a bunch of things which affect PocketMine's performance other than PHP.
     
  7. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Also note that you can't have two event listeners in the same Listener class for the same event and priority.
     
    jasonwynn10 and mal0ne_23 like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.