You are reading a single comment by @JumJum and its replies. Click here to read the full conversation.
  • hmm, there must be something different in our testing.
    To compare Original Espruino Board with ESP32 I wrote some Q&U functions (quick and ugly)
    As a first result I couldn't find any way to come down to 20ms, as you mentioned.
    Strange results, in my eyes, are:

    • setting a pin is 3 times slower on ESP32
    • to figure out how much time goes to ESP-IDF, a simple test function is added to Source, which calls jshPinSetValue with true and with false. This takes a few ms only.
    • array copy from a big array already takes much more than 20 ms
    • LedShiftout which is similiar to the command in your module takes even more time
    • if setting a pin only takes some microsecs, why does setting with pin.set() take close to a millisec

      var pin;
      case "ESPRUINOBOARD": pin = B5; break;
      case "ESP32": pin = D5; break;
      function test(fnc){
      var t = new Date();
      console.log(fnc.substr(3), ":" ,parseInt(new Date() -t));
      function tstLoop(cnt){
      for(var i = 0; i < cnt; i++){}
      function tstArr(cnt){
      var o;for(var i = 0; i < cnt; i++){o = new Uint8Array(1024);}
      function tstPin(cnt){
      for(var i = 0; i < cnt; i++){pin.set();}
      function tstArrCopy(cnt){
      var c,o = new Uint8Array(1024);
      for(var i = 0; i < cnt; i += 4){
      c = new Uint8Array(o,i,64);
      function tstDigitalWrite(cnt){
      var dfnc = digitalWrite.bind(null,[pin,pin,pin,pin,­pin,pin,pin]);
      for(i = 0; i < cnt; i++){
      function tstShiftOut(cnt){
      var arr = new Uint8Array(64);
      var sfnc = shiftOut.bind(null,[pin,pin,pin,pin,pin,­pin],{clk:pin});
      for(var i = 0; i < cnt; i++){
      function tstLedShiftOut(cnt){
      var arr = new Uint8Array(1024);
      var sfnc = shiftOut.bind(null,[pin,pin,pin,pin,pin,­pin],{clk:pin});
      for(var i = 0; i < cnt; i++){
      sfnc(new Uint8Array(arr,i*64,64));
      function tstjshPinSetValue(cnt){
      case "ESP32": test("tstjshPinSetValue(6144)"); break;

    Result in Millisconds of running test on both boards

    TestEspruino BoardESP32
    Loop(1000) 197230
    Arr(100) 109134
    Pin(1000) 342915
    ArrCopy(16) 15176
    ShiftOut(16) 1430
    LedShiftOut(16) 652396
    DigitalWrite(16) 819
    jshPinSetValue(6144)not available11


Avatar for JumJum @JumJum started