-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.php
executable file
·29 lines (25 loc) · 987 Bytes
/
stats.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
<?php
require_once('vendor/autoload.php');
set_time_limit(-1);
error_reporting(E_ALL);
ini_set('display_errors', true);
function setUp2Levels()
{
$array = range(0, 1000);
$shuffleTime = 0;
$time = microtime(true);
$collection = new \ArrayGrouper\Grouper\Collection($array);
$collection->registerGroupingFunction('byRandom', function($element) { return rand(0,5); });
$collection->registerGroupingFunction('evenUneven', function($element) { return $element % 2; });
for ($i = 0; $i < 100; $i++) {
shuffle($array);
$collection->groupByDescending('key', array('byRandom'));
$collection->groupBy('testGroup', array('evenUneven'));
$collection->groupByDescending('key2', array('byRandom'));
$G =$collection->apply($array);
echo $G;
}
return microtime(true) - $time - $shuffleTime;
}
echo 'setting up 1000 times a structured group using two functions took:' . setUp2Levels() . ' seconds';
echo '<hr />';