- Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
Process exited with code 137.
<?php
class Person
{
function __construct($c)
{
$this->count = $c;
}
function getPrev()
{
return $this->prev;
}
function setPrev($pr)
{
$this->prev = $pr;
}
function getNext()
{
return $this->next;
}
function setNext($nxt)
{
$this->next = $nxt;
}
function shout($shout, $nth)
{
if ($shout < $nth)
{
return $shout + 1;
}
$this->getPrev()->setNext($this->getNext());
$this->getNext()->setPrev($this->getPrev());
return 1;
}
}
class Chain
{
var $first;
function __construct($size)
{
$last =null;
for($i = 0; $i < $size ; $i++)
{
$current = new Person($i);
if ($this->first == null) $this->first = $current;
if ($last != null)
{
$last->setNext($current);
$current->setPrev($last);
}
$last = $current;
}
$this->first->setPrev($last);
$last->setNext($this->first);
}
function kill($nth)
{
$current = $this->first;
$shout = 1;
while($current->getNext() !== $current)
{
$shout = $current->shout($shout,$nth);
$current = $current->getNext();
}
$this->first = $current;
}
}
$start = microtime(true);
$ITER = 100000;
for($i = 0 ; $i < $ITER ; $i++)
{
$chain = new Chain(40);
$chain->kill(3);
}
$end = microtime(true);
printf("Time per iteration = %3.2f microsecondsnr",(($end - $start) * 1000000 / $ITER));