Code tuning and differences between simulator and real devices


I have made a short demo (https://drive.google.com/open?id=0By...wLVp5SmdNSTg)* for the forum members today to check some graphic functions - in the simulator the program works relatively smooth but on my FR935 it seems to be significant slower. It's clear for me that the simulator is a simulator, not an emulator and it would be impossible to get a "perfect" simulation for all (!) different devices...

...but are there already some experiences about some bigger shifts between simulator and some devices? I would mention fonts here which look different on my watch and which sometimes mean working hard to find the best x|y values for the text coordinates (that is quite interesting, because the font files of the SDK need quite a lot of disk space)

...and what about speed? Does anyone give some hints what should work fine or where things won't work as expected? Which functions are relatively slow, where the compiler makes optimized code and where not? (e.g. should I prefer 'i=i+i/2' or 'i=i+i>>1'... [TEXT NOT COMPLETE]

*) play with 'Start', 'Up' and 'Down' - to quit the game before you have completed all levels, press 'Back' and 'Down'
  • if you notice a difference between simulator and real device you should file a bug report in the bug report forum, so that the connect iq team can have it fixed in a next sdk release.
  • Post more details than just "json error", as you may not be seeing a difference between the sim and a device, but between a computer and a phone. The most visible is the speed to get a response. It's much slower with a phone, as you got BLE and the phones inet access in the mix.

    You may also be seeing something involving GCM/Android vs GCM/iOS. Just in the last few weeks, there was a problem where GCM/A was returning Numbers as Floats (in 3.19 that was fixed in 3.19.1.

    Another developer (HermoT) found something with the format he used to do the makeWebRequest worked fine with iOs and the sim, but not with Android. But he found a way to make the request so that worked with both. (if I recall, he was getting a -400 with an Android phone before the fix). Not a problem with the sim or watch, but a difference/problem in the version of GCM, but one to work around.

    You could also be hitting something in testing where on the watch, your request is resulting in more data/a more complex response is being returned than you saw in the sim.
  • When I started this thread, I had entered a quite nice text, but the forum answered with a JSON error message... I didn't gave up, but after hours of playing the new adventure I am totally lost. Sometimes it look promising (choose "RESTORE" or "DISCARD") but this doesn't take for long, because of "ERROR 403", "JSON Error", "NOT AUTHORIZED", "DOES NOT EXIST", "ERROR LOADING PREVIEW" and "ERROR FORBIDDEN" are waiting for you :)

    Now I have spent again a while to write the text again (without emoticons, bold font and other gimmicks), and the forum had also a new message for me "ILLEGAL CHARACTER"...


    STILL TRYING TO ADD THE CORRECT TEXT IN THE FIRST POST...
  • I would mention fonts here which look different on my watch and which sometimes mean working hard to find the best x|y values for the text coordinates (that is quite interesting, because the font files of the SDK need quite a lot of disk space)


    with this one, are you using native fonts or custom fonts? Are you using the latest SDK? With native fonts, if I sim a 935, things look the same on a real 935. If I sim a f3, they look way different on a 935. (not all rounds are the same).
  • The simulator of the latest SDK does not work here, so I am using 2.2.6 - and the native fonts are set completely different on the simulator (of course compiler and simulator is set to the FR935), hopefully I can add screen shots here...
    ...no, the forum tells me 'invalid file format'?!

    So here are the links:
    - https://sites.google.com/site/mrvogel/Files/SIM226.png
    - https://sites.google.com/site/mrvogel/Files/FR935.png
  • That looks to be a bug to me. You probably want to do a bug report with the pictures and the code you use to display this.
  • Sorry about the weard start of this thread (I am still unable to finish the text of the first post)...

    ...here's another try for one of the points I want to discuss here: S P E E D

    Does anyone know about the execution time of the following lines?
    // init
    const two=2;
    var anothertwo=2;

    // calculation
    i=i+i/2; // A
    i=i+i>>1; // B
    i+=i>>1; // C
    i+=i*0.5; // D
    i+=two; // E
    i+=anothertwo; // F


    How to speed up graphics?
    * will a transparent background color influence the drawing speed?
    * will a custom font without antialiasing be drawn quicker than an internal?


    Waht are your experiences? Which routines are slow and should be avoided? Do you have found some good solutions to speed up your code?
  • You could use use Sys.getTime() and check the time it takes to run each variation a 1000 times or something and see the difference, or I know Travis has demonstrated how to show the byte code generated for each line which also might give you some info. (I think it's an option to the compiler)

    But step back a bit - what is it you're trying to correct? Is it just that you want to make the code as fast as possible, or is it a specific problem?
  • Former Member
    Former Member
    Sorry about the weard start of this thread (I am still unable to finish the text of the first post)...

    ...here's another try for one of the points I want to discuss here: S P E E D

    Does anyone know about the execution time of the following lines?
    // init
    const two=2;
    var anothertwo=2;

    // calculation
    i=i+i/2; // A
    i=i+i>>1; // B
    i+=i>>1; // C
    i+=i*0.5; // D
    i+=two; // E
    i+=anothertwo; // F


    How to speed up graphics?
    * will a transparent background color influence the drawing speed?
    * will a custom font without antialiasing be drawn quicker than an internal?


    Waht are your experiences? Which routines are slow and should be avoided? Do you have found some good solutions to speed up your code?


    Executing on the VM is slow, regardless of what you are doing. You can test the operations you have listed as Jim described, but they are likely to all be the same order of magnitude because the VM execution dwarfs the speed of the actual math operations that ultimately get executed on the core.

    I don't think transparency will influence drawing speed for most operations. I is possible elements with transparency are slightly slower in some cases, but I would guess not.
    When I tested the speed of fonts, anti-aliased fonts seemed to render at about the same speed as ones that are not anti-aliased. They are both quite slow compared to other rendering.
  • The forum doesn't like me: JSON errors, wrong image file format and the whole game starts again...
    ...I copied my message into the notepad and paste it here - the forum loves endless "WORKING" :(