當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayUtil::findModes方法代碼示例

本文整理匯總了PHP中ArrayUtil::findModes方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayUtil::findModes方法的具體用法?PHP ArrayUtil::findModes怎麽用?PHP ArrayUtil::findModes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ArrayUtil的用法示例。


在下文中一共展示了ArrayUtil::findModes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: formatOutput

    /**
     * Format and echo output from extracted data
     * @param $method
     * @param $requestPath
     * @param array $summary
     */
    protected function formatOutput($method, $requestPath, array $summary)
    {
        // these 3 aren't really needed.
        // here for:
        // 1- To not give warnings in IDE about unknown variables
        // 2- To set a default value, always a safer practice.
        $dynos = array();
        $totalOccurrences = 0;
        $responseTimes = array();
        extract($summary);
        if (!$totalOccurrences) {
            // not using die() as it causes issue with ob_*
            echo "No occurrences of {$method} {$requestPath} found" . PHP_EOL;
            return;
        }
        $mostCommonDyno = ArrayUtil::findModes($dynos);
        $leastCommonDyno = ArrayUtil::findLeastCommonValues($dynos);
        $meanResponseTime = ArrayUtil::findMean($responseTimes);
        $medianResponseTime = ArrayUtil::findMedian($responseTimes);
        $modeResponseTimes = ArrayUtil::findModes($responseTimes);
        $minResponseTime = min($responseTimes);
        $maxResponseTime = max($responseTimes);
        $summary = <<<SUMMARY
        Number of times request was made: %d
        Most active Dyno(s): %s
        Least active Dyno(s): %s
        Min. Response Time: %d
        Max. Response Time: %d
        Mean Response Time: %f
        Median Response Time: %f
        Mode Response Time(s): %s

SUMMARY;
        echo sprintf($summary, $totalOccurrences, implode(', ', $mostCommonDyno), implode(', ', $leastCommonDyno), $minResponseTime, $maxResponseTime, $meanResponseTime, $medianResponseTime, implode(', ', $modeResponseTimes));
    }
開發者ID:shoaibi,項目名稱:heroku-log-parser,代碼行數:41,代碼來源:LogParser.php

示例2: testFindModeWithSingleMultipleCommonElementsArray

 /**
  * @depends testFindModeWithSingleMostCommonElementArray
  */
 public function testFindModeWithSingleMultipleCommonElementsArray()
 {
     $mode = ArrayUtil::findModes(array(1, 2, 4, 2, 1));
     $this->assertEquals(array(1, 2), $mode);
 }
開發者ID:shoaibi,項目名稱:heroku-log-parser,代碼行數:8,代碼來源:ArrayUtilTest.php


注:本文中的ArrayUtil::findModes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。