-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathspeed-analysis.php
49 lines (44 loc) · 1.72 KB
/
speed-analysis.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
$start_time = microtime(TRUE);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Speed Analysis</title>
<script language="javascript" type="text/javascript" src="jquery.min.js"/></script>
<script type="text/javascript">
var startTime = (new Date()).getTime();
</script>
</head>
<body>
<?php
print "Speed Analysis, without any data and database connection";
?>
<?php
$end_time = microtime(TRUE);
$time_taken_sec = $end_time - $start_time;
$server_timemilli = $time_taken_sec*1000;
$time_taken = round($time_taken_sec,5);
?>
<div style="background:#F9D350;color:#A94C17" id="load_timediv"></div>
<script type="text/javascript">
var server_time='';
var browser_time= '';
$(window).load(function()
{
var endTime = (new Date()).getTime();
var millisecondsLoading = endTime - startTime;
// Put millisecondsLoading in a hidden form field
// or AJAX it back to the server or whatever.
var seconds = (millisecondsLoading/1000);
var htmlStr = 'Total load time in seconds : '+seconds+' :: in ms :' + millisecondsLoading;
server_time=<?php print $server_timemilli; ?>; // for ajax insert
browser_time= millisecondsLoading; // for ajax insert
var disptime = <?php print $time_taken; ?>;
var totaltime_display = seconds + disptime;
document.getElementById('load_timediv').innerHTML = 'Total elapsed time: '+totaltime_display.toFixed(4)+' sec. ==> Server: '+disptime+' sec. | User (e.g. : browser,network,internet): '+seconds.toFixed(4) +' sec.';
});
</script>
</body>
</html>