How can I know code execution time and code execution time limitation in the code

I want to get code execution time and code execution time limitations in the code , If time not permitting, another code will not be executed.

  • In general, you can't but the watchdog timer will trigger if you run too long.

    The exception is with watch faces, where in the sim, under File, there is "view watch face diagnostics", that will give you info on things like your execution time in onPartialUpdate() to help you keep under the 30ms avg execution times.

    You can use Sys.getSystemTimer() and insert it into your code to get info on specific sections of code though, but using something like Sys.printlin can infuence it, so you want to collect the info and print it when you're done.

  • like jim said - use SystTimer() as println lines before and after the code execution to get an idea

  • I can't find .getSystemTimer() within System.

    Did you mean .getTimer()? Or something else?

    Doc says there are:

    • error(msg)

      Write an error to the console and exit the system.

    • exit()

      End execution of the current app.

    • exitTo(intent)

      Exit the current app and launch a new app.

    • getClockTime() ⇒ Toybox.System.ClockTime

      Get the current clock time.

    • getDeviceSettings() ⇒ DeviceSetting

      Get the current device settings.

    • getSystemStats() ⇒ Toybox.System.Stats

      Get the current system stats.

    • getTimer() ⇒ Toybox.Lang.Number

      Get the current millisecond timer value.

    • isAppInstalled(uri) ⇒ Toybox.Lang.Boolean

      Check the installation status of an app.

    • print(output)

      Print to the console.

    • println(output)

      Print to the console with a line terminator.

  • Yes, Sys.getTimer().

    The system millisecond timer.

  • What is absolute value of Sys.getTimer()? It seems I can't find since which moment it calculated?

  • It's the number milliseconds since you turned on the watch and will increase until it wraps.  It's a 32 bit value.