You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Are all those arrays typed arrays? Accessing those should be quite quick, but accessing large, normal arrays is slow. Mind you, your arrays really aren't that large.

    It also helps if all the variables you're accessing are defined in the function itself, but it looks like you're doing that.

    Actually even finding a variable based on name is a bit slow, and for an array access you're finding at least 2 variables.

    So something like b[i]=b[i]+(z[i]>b[i]?1:-1); would be faster as b[i]+=z[i]>b[i]?1:-1;

    Compiled code is also potentially an option?


Avatar for Gordon @Gordon started