public function testCalcMedian() { $this->container->expects($this->once())->method('has')->will($this->returnValue(true)); $this->container->expects($this->once())->method('get')->will($this->returnValue(10)); $this->container->expects($this->once())->method('set')->with($this->equalTo('Foo.bar'), $this->equalTo(7.5)); $this->blobStore->expects($this->once())->method('save'); $instance = new TransientStatsdCollector($this->blobStore, 42); $instance->calcMedian('Foo.bar', 5); $instance->saveStats(); }
private function addQueryResultToCache($queryResult, $queryId, $container, $query) { $this->transientStatsdCollector->incr('misses'); $this->transientStatsdCollector->calcMedian('medianRetrievalResponseTime.uncached', round(microtime(true) - $this->start, 5)); $callback = function () use($queryResult, $queryId, $container, $query) { $this->doCacheQueryResult($queryResult, $queryId, $container, $query); }; $deferredCallableUpdate = ApplicationFactory::getInstance()->newDeferredCallableUpdate($callback); $deferredCallableUpdate->setOrigin(__METHOD__); $deferredCallableUpdate->setFingerprint(__METHOD__ . $queryId); $deferredCallableUpdate->pushToUpdateQueue(); }