Console.time () on iOS Safari

I'm trying to optimize a web application for the iPad (iOS 5.1.1), and I was wondering how to measure the time spent on the function .

On the desktop there is console.time () and console.timeEnd () for the firebug and webkit console. Unfortunately, I cannot get it to work on iOS , only console.log () is supported.

Any alternatives?

+4
source share
3 answers
var start = new Date().getTime(); // .... var end = new Date().getTime(); console.log(end-start); 
+2
source

Based on xdazz's answer , I tried replacing two functions so that it worked on iOS without refactoring all timers:

 if(!console){var console = {};} // for those without a console - mind the context console.timers = {}; console.time = function(timer) { if(!timer){timer="Timer";} console.timers[timer] = new Date().getTime(); }; console.timeEnd = function(timer) { if(!timer){timer="Timer";} console.log(timer+": "+(new Date().getTime()-console.timers[timer])); }; 

Warning : this will replace the original API and therefore may provide less accurate data on your desktop browsers.

0
source

Like iPhone 4 CDMA with iOS 6, Mobile Safari supports console.time() and console.timeEnd() .

0
source

All Articles