-
Notifications
You must be signed in to change notification settings - Fork 4
/
cpu-stress-test.php
57 lines (48 loc) · 1.12 KB
/
cpu-stress-test.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
50
51
52
53
54
55
56
<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
?>
<!DOCTYPE html>
<html>
<body>
<div align="center">
<h1 style="font-family:verdana;">CPU Stress test Page</h1>
<p style="font-family:verdana;font-size:130%;color:black">
<?php
echo "This machine is: ";
echo gethostname();
?>
</p>
<?php
$EC2_AZ=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone`;
if ($EC2_AZ == 'us-west-2a') $COLOR="blue";
if ($EC2_AZ == 'us-west-2b') $COLOR="green";
if ($EC2_AZ == 'us-west-2c') $COLOR="red";
echo '<p style="font-family:verdana;font-size:180%;color:'.$COLOR.'">'.$EC2_AZ;
?>
</p>
<br><br><br>
<p style="font-family:verdana;font-size:120%;color:black">
CPU Stress test performed.
</p>
<?php
// CPU stress test
for($i = 0; $i < 100000000; $i++) {
$a += $i;
}
?>
<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo '<p style="font-family:verdana;font-size:90%;color:black">';
echo 'Page generated in '.$total_time.' seconds.';
echo '</p>';
?>
</div>
</body>
</html>