The test codes using 'net' module on Esp32. very fast.
function onInit(){ var ssid = "HGiga3"; var wifiOpts = {password:"20071203"}; var wifi = require("Wifi"); wifi.connect(ssid, wifiOpts, function(err){ console.log("connected? err=", err, "info=", wifi.getIP()); var client = require("net").connect({host: "192.168.1.9", port: 5004}, function() { console.log("connected"); //ws.send('hello, server'); var packet = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; var pktNum = 0; var ta = 0; var id = setInterval(function(){ var t1 = getTime(); client.write(packet); pktNum ++; console.log("Packet NO.: " + pktNum + ", time used: " + (t2 = getTime() - t1) + "s"); ta += t2; if(pktNum >=101){ console.log("total time used: " + ta +"s"); clearInterval(id); } }, 0); }); }); } // END OF : function onInit(){
result:
connected? err= null info= { "ip": "192.168.1.30", "netmask": "255.255.255.0", "gw": "192.168.1.1", "mac": "30:ae:a4:03:96:a8" } connected Packet NO.: 1, time used: 0.004231s Packet NO.: 2, time used: 0.006114s Packet NO.: 3, time used: 0.004296s Packet NO.: 4, time used: 0.004198s Packet NO.: 5, time used: 0.004113s Packet NO.: 6, time used: 0.005927s Packet NO.: 7, time used: 0.004045s Packet NO.: 8, time used: 0.004094s Packet NO.: 9, time used: 0.006462s Packet NO.: 10, time used: 0.004759s Packet NO.: 11, time used: 0.004114s Packet NO.: 12, time used: 0.007091s Packet NO.: 13, time used: 0.006509s Packet NO.: 14, time used: 0.004279s Packet NO.: 15, time used: 0.005615s Packet NO.: 16, time used: 0.004196s Packet NO.: 17, time used: 0.003922s Packet NO.: 18, time used: 0.004579s Packet NO.: 19, time used: 0.003968s Packet NO.: 20, time used: 0.003939s Packet NO.: 21, time used: 0.004289s Packet NO.: 22, time used: 0.004283s Packet NO.: 23, time used: 0.003999s Packet NO.: 24, time used: 0.003984s Packet NO.: 25, time used: 0.004023s Packet NO.: 26, time used: 0.004017s Packet NO.: 27, time used: 0.004048s Packet NO.: 28, time used: 0.004591s Packet NO.: 29, time used: 0.004092s Packet NO.: 30, time used: 0.004068s Packet NO.: 31, time used: 0.00434s Packet NO.: 32, time used: 0.004269s Packet NO.: 33, time used: 0.004151s Packet NO.: 34, time used: 0.004142s Packet NO.: 35, time used: 0.004177s Packet NO.: 36, time used: 0.004166s Packet NO.: 37, time used: 0.004199s Packet NO.: 38, time used: 0.004697s Packet NO.: 39, time used: 0.00427s Packet NO.: 40, time used: 0.004582s Packet NO.: 41, time used: 0.00449s Packet NO.: 42, time used: 0.004288s Packet NO.: 43, time used: 0.004275s Packet NO.: 44, time used: 0.004271s Packet NO.: 45, time used: 0.004327s Packet NO.: 46, time used: 0.004298s Packet NO.: 47, time used: 0.004333s Packet NO.: 48, time used: 0.005087s Packet NO.: 49, time used: 0.004388s Packet NO.: 50, time used: 0.004353s Packet NO.: 51, time used: 0.004907s Packet NO.: 52, time used: 0.004524s Packet NO.: 53, time used: 0.00496s Packet NO.: 54, time used: 0.00446s Packet NO.: 55, time used: 0.00546s Packet NO.: 56, time used: 0.005477s Packet NO.: 57, time used: 0.00445s Packet NO.: 58, time used: 0.004393s Packet NO.: 59, time used: 0.004385s Packet NO.: 60, time used: 0.004417s Packet NO.: 61, time used: 0.004403s Packet NO.: 62, time used: 0.004368s Packet NO.: 63, time used: 0.004339s Packet NO.: 64, time used: 0.00434s Packet NO.: 65, time used: 0.004344s Packet NO.: 66, time used: 0.0043s Packet NO.: 67, time used: 0.004294s Packet NO.: 68, time used: 0.004246s Packet NO.: 69, time used: 0.00437s Packet NO.: 70, time used: 0.004324s Packet NO.: 71, time used: 0.005413s Packet NO.: 72, time used: 0.004527s Packet NO.: 73, time used: 0.004495s Packet NO.: 74, time used: 0.004142s Packet NO.: 75, time used: 0.004123s Packet NO.: 76, time used: 0.004212s Packet NO.: 77, time used: 0.0057s Packet NO.: 78, time used: 0.00406s Packet NO.: 79, time used: 0.004445s Packet NO.: 80, time used: 0.004121s Packet NO.: 81, time used: 0.004131s Packet NO.: 82, time used: 0.004038s Packet NO.: 83, time used: 0.003966s Packet NO.: 84, time used: 0.004073s Packet NO.: 85, time used: 0.006238s Packet NO.: 86, time used: 0.004172s Packet NO.: 87, time used: 0.005971s Packet NO.: 88, time used: 0.005622s Packet NO.: 89, time used: 0.006437s Packet NO.: 90, time used: 0.004657s Packet NO.: 91, time used: 0.006027s Packet NO.: 92, time used: 0.004347s Packet NO.: 93, time used: 0.004164s Packet NO.: 94, time used: 0.003917s Packet NO.: 95, time used: 0.006005s Packet NO.: 96, time used: 0.006223s Packet NO.: 97, time used: 0.004181s Packet NO.: 98, time used: 0.006128s Packet NO.: 99, time used: 0.004149s Packet NO.: 100, time used: 0.006002s Packet NO.: 101, time used: 0.004063s total time used: 0.465458s
@Aifer started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
The test codes using 'net' module on Esp32. very fast.
result: