#What are the most computationally expensive events to use?

1 messages · Page 1 of 1 (latest)

blazing marsh
#

I am creating a modpack and I have an absolutely insane amount of code written for it (close to 10,000 lines with kjs) and I know I can optimize it. So I am wondering what are the most expensive events to use?

I know that PlayerEvents.tick is likely the most expensive so I have tried to remove that one entirely.

glacial spireBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

cursive yacht
#

That question is reletively difficult to answer as there's no "expensive" event.

#

It's about what code you run inside of that event

#

and the amount of calls it gets

#

which varies a lot thorugh gameplay

#

You don't really need to worry that much about Startup events and events that run only once per world join

#

If you're using any tick event it may make sense to only actually run your code every second

#

that's what I'm doing for a project I'm making rn, it's running some quite expensive code, every second and as such it allows abouit 500+ blocks to be placed that run these expensive functions.

#

also if possible use java functions instead of js custom code ?

#

so instead of if(item.id == "myid") do item.is("myid")

#

imo it's more important to write performant and good code then not using specific events

cursive yacht
blazing marsh
#

Is that pretty decent?

cursive yacht
cursive yacht
#

So I've run the number and it actually doesn't matter which you use

#

I have even noticed that equals is actually slightly faster ~ 3-4 % for normal, and ~ 9 % for inverted

#

time to change all my code again