Jump to content
Sign in to follow this  
lynkfs

console

Recommended Posts

I recently revisited the console object, available in all browsers, and discovered some newbies I didn't know about. The methods and properties below may be sometimes useful for debugging purposes.

The console object is tied to the global window object, so access either by

browserapi.window.console.log('whatever');

or define a reference to the window object :

var window   external 'window':   variant;
and call like 
window.console.dirxml(self);

Some console methods are wrapped in SmartCL.System (like writeln ea) and SmartCL.Console

The console.dirxml() above gives an xml representation of any object, which is way better than the 'object Object' result of a console.log(some object) instruction

For performance testing, console also offers native timers

  • console.time()
  • console.timeLog()
  • console.timeEnd()

The above respectively initiate, report and destroy a named timer. The maximum nr of concurrent timers is 10,000 (!)

To see how this works I created a stock new visual project with a single form and no visual controls. 
A timer was inserted at the beginning of the generated js projectfile, at the initialization of the form and at the ApplicationStarting, InitializeForm, InitializeObject and Resize events. Results :

                       console.timeLog
top of main.js :       0.0009765625   ms
Initialization        10.574951171875 ms
applicationstarting   17.234130859375 ms
InitializeObject      21.23095703125  ms
ReSize                62.385986328125 ms
ReSize               101.25           ms
InitializeForm       225.994140625    ms
ReSize               226.757080078125 ms

Wondering about the multiple ReSize calls and the relatively large time lag between InitializeObject and InitializeForm.

There is another feature built into browsers re performance : the window.performance object with its own api's

The most useful methods of this object are performance.now(), which gives a high res timestamp, and performance.toJSON() which gives a json representation of the attributes of the performance object

Below the 'console.timer' and 'performance.now' results of a minimum project with 1 form and no visual controls in the native framework : 

                       console.timeLog      performance.now()               
top of main.js :       0.001953125   ms  /  118.28000005334616 timestamps
Initialization         2.16186523437 ms  /  120.43999996967614
InitializeForm         3.61083984375 ms  /  121.92000006325543
InitializeObject       4.32080078125 ms  /  122.65000003390014

and some values for the attributes of the performance object itself (console.log(window.JSON.stringify(window.performance.toJSON()));)

timeOrigin :               1564383720413.3972  timestamps
navigationStart:           1564383720413
redirectStart:             0
redirectEnd:               0
fetchStart:                1564383720414
domainLookupStart:         1564383720418
domainLookupEnd:           1564383720418
connectStart:              1564383720418
connectEnd:                1564383720418
secureConnectionStart:     0
requestStart:              1564383720418
responseStart:             1564383720423
responseEnd:               1564383720426
unloadEventStart:          1564383720432
unloadEventEnd:            1564383720432
domLoading:                1564383720435
domInteractive:            0
domContentLoadedEventStart:0
domContentLoadedEventEnd:  0
domComplete:               0
loadEventStart:            0
loadEventEnd:              0


 
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×