Fastest way to execute a varying size list of operations between 10,000 and 40,000

I am having to make a system where, every update, around 10,000 to 40,000 operations have to be run, these aren’t heavy operations, but there is alot of them.

The thing peculiar about this problem is that every frame this list of operations will change. To run the operation it requires two ushort variables to be stored.

So right now what I have is two ushort arrays initialized to 40,000 instances. The program will go through and figure out all the operations it must do this frame, adding the two necessary values into the ushort arrays. Then it will iterate through those ushort arrays and do all the operations. Then reset the ushort arrays for the next frame, repeat. This is working fine, but I am wondering, is there a faster way?

Is there any faster way to potentially cue up 40,000 simple arithmetic tasks, and then have them execute? I thought about adding them to an event handler, but that seems like it’d be way slower than iterating through a huge array. I thought maybe using a List, so then it could dynamically resize, but List are slower than arrays aren’t they?

Initialize the arrays to the maximum size you expect to use, and then just reuse those same arrays all the time. When it comes to primitive types, Lists are substantially slower than arrays.

–Eric