Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26115] TiAPI: Add support for console.timeLog

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2018-07-11T20:20:50.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.5.0
ComponentsTiAPI
Labelsandroid, ios, windows
ReporterChristopher Williams
AssigneeEwan Harris
Created2018-06-08T14:53:01.000+0000
Updated2018-12-19T19:29:03.000+0000

Description

it would be very useful to have the ability to output timing to the log for testing and debugging. We have already added console.time and console.timeEnd. Due to some ambiguities around calling timeEnd multiple times for the same label, they introduced console.timeLog to handle printing intermediate timings without removing the timer/label. We should expand to support this as well. https://github.com/whatwg/console/pull/138

Comments

  1. Christopher Williams 2018-06-13

    Also note that there's a good number of other apis we may want to consider adding to match web/node compatibility. https://nodejs.org/api/console.html https://github.com/nodejs/node/blob/master/lib/console.js https://developer.mozilla.org/en-US/docs/Web/API/Console I think the most relevant methods are: - assert - count - countReset - group - groupEnd - table
  2. Hans Knöchel 2018-06-21

    +1 for group, groupEnd and table!
  3. Ewan Harris 2018-06-22

    [~cwilliams]/[~hknoechel] Do either of you share concerns of landing this before the spec lands. I'd like to get this in when time permits but I'm hesitant to do so while it's not full part of the spec. For the others, I think the ones you called out make sense to implement. But I would like to maybe wait until TIMOB-26015 lands, then try and align all platforms to use the same code rather than 2 similar JS implementations and 1 Objective-C one, does that makes sense to you, and am I understanding the potential of that feature correctly?
  4. Ewan Harris 2018-07-06

    Windows: https://github.com/appcelerator/titanium_mobile_windows/pull/1267 Android/iOS: https://github.com/appcelerator/titanium_mobile/pull/10156
  5. Samir Mohammed 2018-09-13

    *Closing ticket.* Verified improvement on SDK version: 7.5.0.v20180913035354 able to log times, log times with additional information and the ability to handle Arrays and Objects using console.timelog Tested on Windows, iOS and Android. *Test steps*

    Created a new Titanium application

    Added the following code to an application (default application)

       console.time('mytimer'); // Start timer
       console.timeLog('mytimer'); // Log time taken so far
       console.timeLog('mytimer', 'with', 'some', 'extra', 'info'); // Log time taken with extra logging
       console.timeLog('mytimer', [ 'a', 'b', 'c' ], { objects: true }); // Should handle Arrays and Objects
       console.timeEnd('mytimer');

    Installed app on to the device/Simulator

    Ran the app

    Able to see the console output timer with the correct information

    *Environment*
       APPC Studio:  5.1.0.201808080937 (ios/Android) 5.1.1.201809051655 (Windows)
       APPC CLI: 7.0.6
       iphone 6 (12.0)
       Nexus 5x emulator (API 25)
       Operating System Name: Mac OS High Sierra
       Operating System Version: 10.13.6
       Node.js Version: 8.9.1
       Xcode 10.0 beta 6
       
       Windows 10 emulator 10.0.15063.0
       Name = Microsoft Windows 10 Enterprise
       Version = 10.0.15063
       Architecture = 64bit
       CPU Cores = 8
       Memory = 15.9GB
       Node.js = 8.9.1
       Appcelerator CLI = 7.0.6
       

JSON Source