-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmicrotime.php
56 lines (48 loc) · 1.2 KB
/
microtime.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
// microtime
// $time_start = microtime(true);
// ///////////////////////////////
// $i = 1;
// while($i <= 100000) {
// $i++;
// }
// ///////////////////////////////
// $time_end = microtime(true);
// $time = $time_end - $time_start;
// print "Time start: $time_start\n";
// print "Time end: $time_end\n";
// print "Time taken: $time\n";
// $time_start = microtime(true);
// ///////////////////////////////
// for($i= 1; $i <= 100000; $i++) {
// }
// ///////////////////////////////
// $time_end = microtime(true);
// $time = $time_end - $time_start;
// print "Time start: $time_start\n";
// print "Time end: $time_end\n";
// print "Time taken: $time\n";
function test_me($function) {
$time_start = microtime(true);
///////////////////////////////
$function();
///////////////////////////////
$time_end = microtime(true);
$time = $time_end - $time_start;
///////////////////////////////
print "Time start: $time_start\n";
print "Time end: $time_end\n";
print "Time taken: $time\n";
}
test_me(function() {
$i = 1;
while($i <= 100000) {
$i++;
}
});
test_me(function() {
print "Hey";
});
test_me(function() {
print str_repeat("Hey", 100000);
});