2

how to show loading time and memory usage web page in footer with library jquery and angularjs ? ...

I've finished one issue, to show loading time at the library jquery, the following code themselves:

<script type="text/javascript">
before = (new Date()).getTime();
function pageload()
{
    var after = (new Date()).getTime();
    var sec = (after-before)/1000;
    var p = document.getElementById("loadingtime");
    p.innerHTML = "Load In : " + sec + " seconds";  
}
 window.onload = function () 
    { 
        pageload();
    }
</script>

and I write <p id = "loadingtime"> in footer web page. this code from : http://nuelcoding.blogspot.co.id/2016/01/php-javascript-web-page-load-time.html

but, for angularjs I can not yet, anyone can help? ...

and for memory usage I can not at all, either in angularjs or jquery? ...

view eventually will be like this:

Load In: 0.015 seconds | Memory: ... MB

anyone can help, thanks for the answer.

ainun
  • 21
  • 1

2 Answers2

2

For the memory you may find your answer here : jQuery or javascript to find memory usage of page

  window.performance.memory
Community
  • 1
  • 1
Simo
  • 431
  • 1
  • 7
  • 20
1

The Date object seems like the way to go From Mozilla Date

Calculating elapsed time

// using Date objects
var start = Date.now();

// the event to time goes here:
doSomethingForALongTime();
var end = Date.now();
var elapsed = end - start; // elapsed time in milliseconds

Often times Performance.now(), can be even better. Performance.now()

var t0 = performance.now();
doSomething();
var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.")

For memory window.performance.memory, seems like a good benchmark as @simo said

Muntasir Alam
  • 1,777
  • 2
  • 17
  • 26