当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayUtil::findLeastCommonValues方法代码示例

本文整理汇总了PHP中ArrayUtil::findLeastCommonValues方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtil::findLeastCommonValues方法的具体用法?PHP ArrayUtil::findLeastCommonValues怎么用?PHP ArrayUtil::findLeastCommonValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayUtil的用法示例。


在下文中一共展示了ArrayUtil::findLeastCommonValues方法的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: testFindLeastCommonValuesWithMultipleLeastCommonElementsArray

 /**
  * @depends testFindLeastCommonValuesWithSingleLeastCommonElementArray
  */
 public function testFindLeastCommonValuesWithMultipleLeastCommonElementsArray()
 {
     $mode = ArrayUtil::findLeastCommonValues(array(1, 2, 4, 2));
     $this->assertEquals(array(1, 4), $mode);
 }
开发者ID:shoaibi,项目名称:heroku-log-parser,代码行数:8,代码来源:ArrayUtilTest.php


注:本文中的ArrayUtil::findLeastCommonValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。