Lodash filters and their CPU rating

  • Being newer to javascript, I'm curious how CPU intensive lodash and _. functions are to a script. We already know that find commands are particularly CPU heavy.

    What about a _.filter command? or a _.sort command?
    How much CPU does it really take in comparison. Is it worth saving a master list every 500 ticks or so, and then just filtering it out when needed?

    Opinions are welcome.

  • This will ofcourse depend on the dataset that you filter or sort on. I've done some benchmarks and a filter used on average 0.1 CPU (dataset of 20 objects), a sort used a bit more (around 0.3 CPU) on the same dataset.

  • I tried to do some benchmarks in the simulation room. I was getting large ranges on filters and find functions. Anywhere from 1 to 5 CPU on a 75 item filter.

    The room was static, with random structures and creeps spread about. And I still saw a large variation in the needed CPU per tick