File: 035.phpt

package info (click to toggle)
php-msgpack 2.0.2%2B0.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,192 kB
  • ctags: 729
  • sloc: ansic: 6,789; xml: 702; php: 18; makefile: 1
file content (29 lines) | stat: -rw-r--r-- 750 bytes parent folder | download | duplicates (2)
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
--TEST--
Profiling perf test.
--SKIPIF--
--FILE--
<?php
$data_array = array();
for ($i = 0; $i < 5000; $i++) {
    $data_array[random_bytes(10)] = random_bytes(10);
}

$time_start = microtime(true);
for ($i = 0; $i < 4000; $i++) {
    $s = msgpack_serialize($data_array);
    $array = msgpack_unserialize($s);
    unset($array);
    unset($s);
}
$time_end = microtime(true);

if ($time_end <= $time_start) {
    echo "Strange, $i iterations ran in infinite speed: $time_end <= $time_start", PHP_EOL;
} else {
    $speed = $i / ($time_end - $time_start);
    printf("%d iterations took %f seconds: %d/s (%s)\n",
        $i, $time_end - $time_start, $speed, ($speed > 400 ? "GOOD" : "BAD"));
}
?>
--EXPECTF--
%d iterations took %f seconds: %d/s (GOOD)