• Is there some method to enchance the performance of 'ws' ?

    Chances are it's this code that is slowing things down:

    https://github.com/espruino/EspruinoDocs/blob/master/modules/ws.js#L230

    You could probably do something like this to make Espruino head through it 32 bits at a time instead of 8:

    masked = new Uint32Array(1+((msg.length+3)>>2));
    var m8 = new Uint8Array(masked.buffer,0,4+msg.length);
    m8.set(mask,0);
    m8.set(msg,4);
    var m = masked[0];
    for (var i=masked.length-1;i>0;i--)masked[i]^=m;
    // E.mapInPlace could be even faster here
    this.socket.write(m8);
    

    But you'd have to have a play around yourself - I haven't tested that.

About

Avatar for Gordon @Gordon started