-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.php
66 lines (53 loc) · 1.81 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Modified script found at - https://github.com/OrimFoundation/PhpObjectifyTests
*
*/
// start script time
$timeExecutionStart = microtime(true);
// start memory usage
$memoryExecutionStart = memory_get_usage(true);
// start memory peak usage
$peakMemoryExecutionStart = memory_get_peak_usage(true);
// default test to run
$client = 'phpredis';
// number of iterations to do
$iterations = 100000;
// fetch params from CLI
$options = getopt("c:i:m:");
if (array_key_exists('c', $options))
{
$client = $options['c'];
}
if (array_key_exists('i', $options))
{
$iterations = $options['i'];
}
if (array_key_exists('m', $options))
{
$method = $options['m'];
}
include $client.'.php';
$testredis = new Testredis();
$testredis->$method($iterations);
// end script time
$timeExecutionEnd = microtime(true);
// end memory usage
$memoryExecutionEnd = memory_get_usage(true);
// end memory peak usage
$peakMemoryExecutionEnd = memory_get_peak_usage(true);
$timeSpent = 1000 * ($timeExecutionEnd - $timeExecutionStart);
$paddedMemoryExecutionStart = str_pad(number_format($memoryExecutionStart, 0, '.', ','), 10, ' ', STR_PAD_LEFT);
$paddedMemoryExecutionEnd = str_pad(number_format($memoryExecutionEnd, 0, '.', ','), 10, ' ', STR_PAD_LEFT);
$paddedPeakMemoryExecutionEnd = str_pad(number_format($peakMemoryExecutionEnd, 0, '.', ','), 10, ' ', STR_PAD_LEFT);
/*
echo 'Time spent: ' . $timeSpent . ' ms' . PHP_EOL;
echo 'Memory start: ' . $paddedMemoryExecutionStart . ' B' . PHP_EOL;
echo 'Memory end: ' . $paddedMemoryExecutionEnd . ' B' . PHP_EOL;
echo 'Memory peak: ' . $paddedPeakMemoryExecutionEnd . ' B' . PHP_EOL;
*/
echo $timeSpent.PHP_EOL;
echo $paddedMemoryExecutionStart.PHP_EOL;
echo $paddedMemoryExecutionEnd.PHP_EOL;
echo $paddedPeakMemoryExecutionEnd.PHP_EOL;
?>