Is setting the pretokenise flag advisable? #1316
Replies: 11 comments
-
Posted at 2019-05-01 by @gfwilliams With The code's pretokenised at upload time, so you're going to see speed improvements for all execution, even long running stuff. Gotchas? Readability when using |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-05-01 by Steffen Sounds good, I'll give it a try. Thanks for the quick reply. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-05-01 by Steffen It doesn't seem to work from the console neither from the IDE.
Version is 2v02, Espruino Wifi. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-05-02 by @gfwilliams There won't be tokens, because Espruino automatically converts them back to readable text before output - also the function you uploaded doesn't actually contain any reserved words :) Try:
This prints:
You'll notice all the whitespace is gone - that happened inside Espruino rather than being anything the IDE did. Also if you really want to dive around in the internals:
So the function code is now Just as a quick test:
So in something like that you're about 10% faster and you saved a few variables too |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-05-02 by Steffen Wow, this is pretty impressive. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-05-02 by @gfwilliams Not quite I'm afraid :) It works great if you upload to RAM. Anything uploaded after However when you do It's actually an addition that could do into the Web IDE (code could be pre-tokenised in the IDE, so then everything including E.setBootCode would be smaller/faster) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-05-02 by @gfwilliams Ok, so I had a play and just added this to the Web IDE. I haven't updated it yet but I'll try and get it in soon (the files are in GitHub) - should make a big difference in modules with a lot of |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-05-02 by @allObjects ...it - Espruino's progress - cannot get faster than that! Thanks! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-05-04 by Steffen Just had a glance at it and it looks neat. (side note: I once had a Sinclair ZX81 with 1kB of RAM. The code was immediately entered as tokens.) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-05-06 by @gfwilliams
It does, yes :) If you were to manually install the command-line tools from https://github.com/espruino/EspruinoTools then do |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-05-06 by Steffen Glad to hear eval does it :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2019-05-01 by Steffen
I've stumbled upon the pretokenise flag (
E.setFlags({pretokenise:1})
) and I'm wondering if it's worth setting it on an Espruino Puck or WiFi.As far as I can guess pretokenised JS code doesn't need to get eval'ed anymore, which has the potential to speed up execution significantly.
Does it accelerate the execution of long running code, or has the code already been pretokenised after a while?
Are there any gotchas except of readability and changeability of the tokenised code?
Any comments are appreciated.
Beta Was this translation helpful? Give feedback.
All reactions