test_step(count($targets) != 1 ? -1 : 0); @$lookups[$targets[0]]++; } $mean = 0; $deviation = 0; foreach ($lookups as $value) { $mean += $value; } $mean = $mean / count($lookups); foreach ($lookups as $value) { $deviation += pow($value - $mean, 2); } test_end('deviation is ' . sprintf('%.2f', sqrt($deviation / count($lookups)))); test_start('lookupBalance'); $lookups = array(); for ($index = 0; $index < CANDIDATES; $index++) { $target = $chash->lookupBalance('candidate001', 10); test_step($target == '' ? -1 : 0); @$lookups[$target]++; } $mean = 0; $deviation = 0; foreach ($lookups as $value) { $mean += $value; } $mean = $mean / count($lookups); foreach ($lookups as $value) { $deviation += pow($value - $mean, 2); } test_end('deviation is ' . sprintf('%.2f', sqrt($deviation / count($lookups)))); print "\n";