Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
PhoneGap Timing Template
<!doctype html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
<title>PhoneGap App</title>
<script>
var timedEvents = [];
function timeEvent(name) {
timedEvents.push({'name': name || 'unnamed', time: Date.now()});
}
function showTimedEvents() {
var timeText = '';
var timeHtml = '<table>';
for (var i = 0; i < timedEvents.length; i++) {
var timedEvent = timedEvents[i];
timeText += timedEvent.name + ': ' + timedEvent.time;
var diff = '';
if (i > 0) {
diff = (timedEvent.time - timedEvents[i-1].time);
timeText += ' (' + diff + 'ms elapsed)';
}
timeHtml += '<tr><td>' + timedEvent.name + '<td>' + timedEvent.time + '<td>' + diff;
timeText += '\n';
}
console.log(timeText);
document.body.innerHTML += timeHtml;
}
</script>
<script>timeEvent('Before CSS');</script>
<link rel="stylesheet" href="css/all-phonegap-min.css?v=10201550"/>
<script>timeEvent('After CSS');</script>
</head>
<body>
<div>HTML here (more than this)</div>
<script>timeEvent('After HTML');</script>
<script src="js/libs/jquery-1.6.2.min.js"></script>
<script>timeEvent('After jQuery script tag');</script>
<script src="js/all-phonegap-min.js?v=10201550"></script>
<script>timeEvent('After other script tag');</script>
<script>
$(document).ready(function() {
timeEvent('After document ready');
myCustomMobileFunction();
timeEvent('After ready JS called');
showTimedEvents();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment