• Nowadays using new "jit" feature may be good enough to speed things up, can you try replace "compiled" by "jit" and see if speed is good enough? "compiled" makes sense mainly for pure data processing like many math operations in a loop, also it is a bit buggy and the js code should be relatively simple for it to work correctly. Also it produces quite bloated native code. I'd say it is last resort when every other optimization fails.

    BTW it is just a warning, does it not work?

    you can try replacing the ? : operator by simple if else construct

  • Thanks @fanoush.

    The error from "compiled" stops it working and the code is just uploaded as source.

    I have other problems with "jit": it seems not to like '&&' both on the line in question and elsewhere in my code:

    JIT SyntaxError: Got && expected EOF
     at line 3 col 28
            g.setBgColor((bngl && E.getBattery()<10)?63488:(g.th...
                               ^
    

    The following test gives me the same error:

    function test() {
      "jit";
      print((true && false)?'y':'n');
    }
    test();
    

    I do have many maths options in a loop: I'm making a version of https://www.youtube.com/watch?v=IA4UsV04­bnM
    and am rotating 128 lines - there's a couple of screenshots below. I've tried to optimise the code anyway by precomputing the rotated lines, using Int8Arrays and Float32Arrays etc. What's left in the loop is therefore pretty simple arithmetic, indexing into the arrays and comparisons but quite a lot of them. Without compiling I get roughly 1 loop per sec, with I get between two and three per sec so a really good improvement.


    2 Attachments

    • p1.jpg
    • p2.jpg
About

Avatar for BillV @BillV started