0

Hey you all I got a time calculation question. I'm attempting to do a lot of PHP and AJAX code appending to HTML. I want to know if my code below will accurately calculate the time of entire code being executed or solely just the PHP code. If it just calculates the PHP, what other code can I add to give me an accurate length of time it takes for the code to execute.

<?php
$before = microtime(true);
/*
    A bunch of PHP Code
*/
?>
<!DOCTYPE html>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
  $(function () {
        /*
            A bunch of Jquery Code
        */
    });
</script> 

<body>
    A Lot of HTML Code
</body>
</html>
<?php
$after = microtime(true);
echo ($after-$before);
?>
3
Contributors
2
Replies
4
Views
3 Years
Discussion Span
Last Post by diafol
0

The PHP code you posted doesn't measure the execution time of the JavaScript. It just measures the time it took the server to parse the page before sending it to the user and well before the user's browser would even start to process the JavaScript.

I'm sure if you search on "JavaScript measure execution time" that you'll find a lot of good advice and sample code.

0

You can also look at the Inspect Element > Network in Chrome browser to give you an idea of how things are working for in practice.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.