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


PHP cache_helper::get_stats方法代码示例

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


在下文中一共展示了cache_helper::get_stats方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_performance_info


//.........这里部分代码省略.........
    }
    $info['dbqueries'] = $DB->perf_get_reads() . '/' . ($DB->perf_get_writes() - $PERF->logwrites);
    $info['html'] .= '<li class="dbqueries">DB reads/writes: ' . $info['dbqueries'] . '</li> ';
    $info['txt'] .= 'db reads/writes: ' . $info['dbqueries'] . ' ';
    $info['dbtime'] = round($DB->perf_get_queries_time(), 5);
    $info['html'] .= '<li class="dbtime">DB queries time: ' . $info['dbtime'] . ' secs</li> ';
    $info['txt'] .= 'db queries time: ' . $info['dbtime'] . 's ';
    if (function_exists('posix_times')) {
        $ptimes = posix_times();
        if (is_array($ptimes)) {
            foreach ($ptimes as $key => $val) {
                $info[$key] = $ptimes[$key] - $PERF->startposixtimes[$key];
            }
            $info['html'] .= "<li class=\"posixtimes\">ticks: {$info['ticks']} user: {$info['utime']} sys: {$info['stime']} cuser: {$info['cutime']} csys: {$info['cstime']}</li> ";
            $info['txt'] .= "ticks: {$info['ticks']} user: {$info['utime']} sys: {$info['stime']} cuser: {$info['cutime']} csys: {$info['cstime']} ";
        }
    }
    // Grab the load average for the last minute.
    // /proc will only work under some linux configurations
    // while uptime is there under MacOSX/Darwin and other unices.
    if (is_readable('/proc/loadavg') && ($loadavg = @file('/proc/loadavg'))) {
        list($serverload) = explode(' ', $loadavg[0]);
        unset($loadavg);
    } else {
        if (function_exists('is_executable') && is_executable('/usr/bin/uptime') && ($loadavg = `/usr/bin/uptime`)) {
            if (preg_match('/load averages?: (\\d+[\\.,:]\\d+)/', $loadavg, $matches)) {
                $serverload = $matches[1];
            } else {
                trigger_error('Could not parse uptime output!');
            }
        }
    }
    if (!empty($serverload)) {
        $info['serverload'] = $serverload;
        $info['html'] .= '<li class="serverload">Load average: ' . $info['serverload'] . '</li> ';
        $info['txt'] .= "serverload: {$info['serverload']} ";
    }
    // Display size of session if session started.
    if ($si = \core\session\manager::get_performance_info()) {
        $info['sessionsize'] = $si['size'];
        $info['html'] .= $si['html'];
        $info['txt'] .= $si['txt'];
    }
    if ($stats = cache_helper::get_stats()) {
        $html = '<ul class="cachesused list-unstyled m-l-1">';
        $html .= '<li class="cache-stats-heading">Caches used (hits/misses/sets)</li>';
        $text = 'Caches used (hits/misses/sets): ';
        $hits = 0;
        $misses = 0;
        $sets = 0;
        foreach ($stats as $definition => $details) {
            switch ($details['mode']) {
                case cache_store::MODE_APPLICATION:
                    $modeclass = 'application';
                    $mode = ' <span title="application cache">[a]</span>';
                    break;
                case cache_store::MODE_SESSION:
                    $modeclass = 'session';
                    $mode = ' <span title="session cache">[s]</span>';
                    break;
                case cache_store::MODE_REQUEST:
                    $modeclass = 'request';
                    $mode = ' <span title="request cache">[r]</span>';
                    break;
            }
            $html .= '<ul class="cache-definition-stats list-unstyled m-l-1 cache-mode-' . $modeclass . '">';
            $html .= '<li class="cache-definition-stats-heading p-t-1">' . $definition . $mode . '</li>';
            $text .= "{$definition} {";
            foreach ($details['stores'] as $store => $data) {
                $hits += $data['hits'];
                $misses += $data['misses'];
                $sets += $data['sets'];
                if ($data['hits'] == 0 and $data['misses'] > 0) {
                    $cachestoreclass = 'nohits text-danger';
                } else {
                    if ($data['hits'] < $data['misses']) {
                        $cachestoreclass = 'lowhits text-warning';
                    } else {
                        $cachestoreclass = 'hihits text-success';
                    }
                }
                $text .= "{$store}({$data['hits']}/{$data['misses']}/{$data['sets']}) ";
                $html .= "<li class=\"cache-store-stats {$cachestoreclass}\">{$store}: {$data['hits']} / {$data['misses']} / {$data['sets']}</li>";
            }
            $html .= '</ul>';
            $text .= '} ';
        }
        $html .= '</ul> ';
        $html .= "<div class='cache-total-stats row'>Total: {$hits} / {$misses} / {$sets}</div>";
        $info['cachesused'] = "{$hits} / {$misses} / {$sets}";
        $info['html'] .= $html;
        $info['txt'] .= $text . '. ';
    } else {
        $info['cachesused'] = '0 / 0 / 0';
        $info['html'] .= '<div class="cachesused">Caches used (hits/misses/sets): 0/0/0</div>';
        $info['txt'] .= 'Caches used (hits/misses/sets): 0/0/0 ';
    }
    $info['html'] = '<div class="performanceinfo siteinfo">' . $info['html'] . '</div>';
    return $info;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:101,代码来源:moodlelib.php

示例2: get_performance_info


//.........这里部分代码省略.........
        $info = array_merge($filterinfo, $info);
        foreach ($filterinfo as $key => $value) {
            $info['html'] .= "<span class='$key'>$nicenames[$key]: $value </span> ";
            $info['txt'] .= "$key: $value ";
        }
    }

    if (!empty($PERF->logwrites)) {
        $info['logwrites'] = $PERF->logwrites;
        $info['html'] .= '<span class="logwrites">Log DB writes '.$info['logwrites'].'</span> ';
        $info['txt'] .= 'logwrites: '.$info['logwrites'].' ';
    }

    $info['dbqueries'] = $DB->perf_get_reads().'/'.($DB->perf_get_writes() - $PERF->logwrites);
    $info['html'] .= '<span class="dbqueries">DB reads/writes: '.$info['dbqueries'].'</span> ';
    $info['txt'] .= 'db reads/writes: '.$info['dbqueries'].' ';

    $info['dbtime'] = round($DB->perf_get_queries_time(), 5);
    $info['html'] .= '<span class="dbtime">DB queries time: '.$info['dbtime'].' secs</span> ';
    $info['txt'] .= 'db queries time: ' . $info['dbtime'] . 's ';

    if (function_exists('posix_times')) {
        $ptimes = posix_times();
        if (is_array($ptimes)) {
            foreach ($ptimes as $key => $val) {
                $info[$key] = $ptimes[$key] -  $PERF->startposixtimes[$key];
            }
            $info['html'] .= "<span class=\"posixtimes\">ticks: $info[ticks] user: $info[utime] sys: $info[stime] cuser: $info[cutime] csys: $info[cstime]</span> ";
            $info['txt'] .= "ticks: $info[ticks] user: $info[utime] sys: $info[stime] cuser: $info[cutime] csys: $info[cstime] ";
        }
    }

    // Grab the load average for the last minute.
    // /proc will only work under some linux configurations
    // while uptime is there under MacOSX/Darwin and other unices.
    if (is_readable('/proc/loadavg') && $loadavg = @file('/proc/loadavg')) {
        list($serverload) = explode(' ', $loadavg[0]);
        unset($loadavg);
    } else if ( function_exists('is_executable') && is_executable('/usr/bin/uptime') && $loadavg = `/usr/bin/uptime` ) {
        if (preg_match('/load averages?: (\d+[\.,:]\d+)/', $loadavg, $matches)) {
            $serverload = $matches[1];
        } else {
            trigger_error('Could not parse uptime output!');
        }
    }
    if (!empty($serverload)) {
        $info['serverload'] = $serverload;
        $info['html'] .= '<span class="serverload">Load average: '.$info['serverload'].'</span> ';
        $info['txt'] .= "serverload: {$info['serverload']} ";
    }

    // Display size of session if session started.
    if ($si = \core\session\manager::get_performance_info()) {
        $info['sessionsize'] = $si['size'];
        $info['html'] .= $si['html'];
        $info['txt'] .= $si['txt'];
    }

    if ($stats = cache_helper::get_stats()) {
        $html = '<span class="cachesused">';
        $html .= '<span class="cache-stats-heading">Caches used (hits/misses/sets)</span>';
        $text = 'Caches used (hits/misses/sets): ';
        $hits = 0;
        $misses = 0;
        $sets = 0;
        foreach ($stats as $definition => $stores) {
            $html .= '<span class="cache-definition-stats">';
            $html .= '<span class="cache-definition-stats-heading">'.$definition.'</span>';
            $text .= "$definition {";
            foreach ($stores as $store => $data) {
                $hits += $data['hits'];
                $misses += $data['misses'];
                $sets += $data['sets'];
                if ($data['hits'] == 0 and $data['misses'] > 0) {
                    $cachestoreclass = 'nohits';
                } else if ($data['hits'] < $data['misses']) {
                    $cachestoreclass = 'lowhits';
                } else {
                    $cachestoreclass = 'hihits';
                }
                $text .= "$store($data[hits]/$data[misses]/$data[sets]) ";
                $html .= "<span class=\"cache-store-stats $cachestoreclass\">$store: $data[hits] / $data[misses] / $data[sets]</span>";
            }
            $html .= '</span>';
            $text .= '} ';
        }
        $html .= "<span class='cache-total-stats'>Total: $hits / $misses / $sets</span>";
        $html .= '</span> ';
        $info['cachesused'] = "$hits / $misses / $sets";
        $info['html'] .= $html;
        $info['txt'] .= $text.'. ';
    } else {
        $info['cachesused'] = '0 / 0 / 0';
        $info['html'] .= '<span class="cachesused">Caches used (hits/misses/sets): 0/0/0</span>';
        $info['txt'] .= 'Caches used (hits/misses/sets): 0/0/0 ';
    }

    $info['html'] = '<div class="performanceinfo siteinfo">'.$info['html'].'</div>';
    return $info;
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:101,代码来源:moodlelib.php

示例3: test_performance_debug

 public function test_performance_debug()
 {
     global $CFG;
     $this->resetAfterTest(true);
     $CFG->perfdebug = 15;
     $instance = cache_config_testing::instance();
     $applicationid = 'phpunit/applicationperf';
     $instance->phpunit_add_definition($applicationid, array('mode' => cache_store::MODE_APPLICATION, 'component' => 'phpunit', 'area' => 'applicationperf'));
     $sessionid = 'phpunit/sessionperf';
     $instance->phpunit_add_definition($sessionid, array('mode' => cache_store::MODE_SESSION, 'component' => 'phpunit', 'area' => 'sessionperf'));
     $requestid = 'phpunit/requestperf';
     $instance->phpunit_add_definition($requestid, array('mode' => cache_store::MODE_REQUEST, 'component' => 'phpunit', 'area' => 'requestperf'));
     $application = cache::make('phpunit', 'applicationperf');
     $session = cache::make('phpunit', 'sessionperf');
     $request = cache::make('phpunit', 'requestperf');
     // Check that no stats are recorded for these definitions yet.
     $stats = cache_helper::get_stats();
     $this->assertArrayNotHasKey($applicationid, $stats);
     $this->assertArrayHasKey($sessionid, $stats);
     // Session cache sets a key on construct.
     $this->assertArrayNotHasKey($requestid, $stats);
     // Check that stores register misses.
     $this->assertFalse($application->get('missMe'));
     $this->assertFalse($application->get('missMe'));
     $this->assertFalse($session->get('missMe'));
     $this->assertFalse($session->get('missMe'));
     $this->assertFalse($session->get('missMe'));
     $this->assertFalse($request->get('missMe'));
     $this->assertFalse($request->get('missMe'));
     $this->assertFalse($request->get('missMe'));
     $this->assertFalse($request->get('missMe'));
     $endstats = cache_helper::get_stats();
     $this->assertEquals(2, $endstats[$applicationid]['stores']['cachestore_file']['misses']);
     $this->assertEquals(0, $endstats[$applicationid]['stores']['cachestore_file']['hits']);
     $this->assertEquals(0, $endstats[$applicationid]['stores']['cachestore_file']['sets']);
     $this->assertEquals(3, $endstats[$sessionid]['stores']['cachestore_session']['misses']);
     $this->assertEquals(0, $endstats[$sessionid]['stores']['cachestore_session']['hits']);
     $this->assertEquals(1, $endstats[$sessionid]['stores']['cachestore_session']['sets']);
     $this->assertEquals(4, $endstats[$requestid]['stores']['cachestore_static']['misses']);
     $this->assertEquals(0, $endstats[$requestid]['stores']['cachestore_static']['hits']);
     $this->assertEquals(0, $endstats[$requestid]['stores']['cachestore_static']['sets']);
     $startstats = cache_helper::get_stats();
     // Check that stores register sets.
     $this->assertTrue($application->set('setMe1', 1));
     $this->assertTrue($application->set('setMe2', 2));
     $this->assertTrue($session->set('setMe1', 1));
     $this->assertTrue($session->set('setMe2', 2));
     $this->assertTrue($session->set('setMe3', 3));
     $this->assertTrue($request->set('setMe1', 1));
     $this->assertTrue($request->set('setMe2', 2));
     $this->assertTrue($request->set('setMe3', 3));
     $this->assertTrue($request->set('setMe4', 4));
     $endstats = cache_helper::get_stats();
     $this->assertEquals(0, $endstats[$applicationid]['stores']['cachestore_file']['misses'] - $startstats[$applicationid]['stores']['cachestore_file']['misses']);
     $this->assertEquals(0, $endstats[$applicationid]['stores']['cachestore_file']['hits'] - $startstats[$applicationid]['stores']['cachestore_file']['hits']);
     $this->assertEquals(2, $endstats[$applicationid]['stores']['cachestore_file']['sets'] - $startstats[$applicationid]['stores']['cachestore_file']['sets']);
     $this->assertEquals(0, $endstats[$sessionid]['stores']['cachestore_session']['misses'] - $startstats[$sessionid]['stores']['cachestore_session']['misses']);
     $this->assertEquals(0, $endstats[$sessionid]['stores']['cachestore_session']['hits'] - $startstats[$sessionid]['stores']['cachestore_session']['hits']);
     $this->assertEquals(3, $endstats[$sessionid]['stores']['cachestore_session']['sets'] - $startstats[$sessionid]['stores']['cachestore_session']['sets']);
     $this->assertEquals(0, $endstats[$requestid]['stores']['cachestore_static']['misses'] - $startstats[$requestid]['stores']['cachestore_static']['misses']);
     $this->assertEquals(0, $endstats[$requestid]['stores']['cachestore_static']['hits'] - $startstats[$requestid]['stores']['cachestore_static']['hits']);
     $this->assertEquals(4, $endstats[$requestid]['stores']['cachestore_static']['sets'] - $startstats[$requestid]['stores']['cachestore_static']['sets']);
     $startstats = cache_helper::get_stats();
     // Check that stores register hits.
     $this->assertEquals($application->get('setMe1'), 1);
     $this->assertEquals($application->get('setMe2'), 2);
     $this->assertEquals($session->get('setMe1'), 1);
     $this->assertEquals($session->get('setMe2'), 2);
     $this->assertEquals($session->get('setMe3'), 3);
     $this->assertEquals($request->get('setMe1'), 1);
     $this->assertEquals($request->get('setMe2'), 2);
     $this->assertEquals($request->get('setMe3'), 3);
     $this->assertEquals($request->get('setMe4'), 4);
     $endstats = cache_helper::get_stats();
     $this->assertEquals(0, $endstats[$applicationid]['stores']['cachestore_file']['misses'] - $startstats[$applicationid]['stores']['cachestore_file']['misses']);
     $this->assertEquals(2, $endstats[$applicationid]['stores']['cachestore_file']['hits'] - $startstats[$applicationid]['stores']['cachestore_file']['hits']);
     $this->assertEquals(0, $endstats[$applicationid]['stores']['cachestore_file']['sets'] - $startstats[$applicationid]['stores']['cachestore_file']['sets']);
     $this->assertEquals(0, $endstats[$sessionid]['stores']['cachestore_session']['misses'] - $startstats[$sessionid]['stores']['cachestore_session']['misses']);
     $this->assertEquals(3, $endstats[$sessionid]['stores']['cachestore_session']['hits'] - $startstats[$sessionid]['stores']['cachestore_session']['hits']);
     $this->assertEquals(0, $endstats[$sessionid]['stores']['cachestore_session']['sets'] - $startstats[$sessionid]['stores']['cachestore_session']['sets']);
     $this->assertEquals(0, $endstats[$requestid]['stores']['cachestore_static']['misses'] - $startstats[$requestid]['stores']['cachestore_static']['misses']);
     $this->assertEquals(4, $endstats[$requestid]['stores']['cachestore_static']['hits'] - $startstats[$requestid]['stores']['cachestore_static']['hits']);
     $this->assertEquals(0, $endstats[$requestid]['stores']['cachestore_static']['sets'] - $startstats[$requestid]['stores']['cachestore_static']['sets']);
     $startstats = cache_helper::get_stats();
     // Check that stores register through get_many.
     $application->get_many(array('setMe1', 'setMe2'));
     $session->get_many(array('setMe1', 'setMe2', 'setMe3'));
     $request->get_many(array('setMe1', 'setMe2', 'setMe3', 'setMe4'));
     $endstats = cache_helper::get_stats();
     $this->assertEquals(0, $endstats[$applicationid]['stores']['cachestore_file']['misses'] - $startstats[$applicationid]['stores']['cachestore_file']['misses']);
     $this->assertEquals(2, $endstats[$applicationid]['stores']['cachestore_file']['hits'] - $startstats[$applicationid]['stores']['cachestore_file']['hits']);
     $this->assertEquals(0, $endstats[$applicationid]['stores']['cachestore_file']['sets'] - $startstats[$applicationid]['stores']['cachestore_file']['sets']);
     $this->assertEquals(0, $endstats[$sessionid]['stores']['cachestore_session']['misses'] - $startstats[$sessionid]['stores']['cachestore_session']['misses']);
     $this->assertEquals(3, $endstats[$sessionid]['stores']['cachestore_session']['hits'] - $startstats[$sessionid]['stores']['cachestore_session']['hits']);
     $this->assertEquals(0, $endstats[$sessionid]['stores']['cachestore_session']['sets'] - $startstats[$sessionid]['stores']['cachestore_session']['sets']);
     $this->assertEquals(0, $endstats[$requestid]['stores']['cachestore_static']['misses'] - $startstats[$requestid]['stores']['cachestore_static']['misses']);
     $this->assertEquals(4, $endstats[$requestid]['stores']['cachestore_static']['hits'] - $startstats[$requestid]['stores']['cachestore_static']['hits']);
     $this->assertEquals(0, $endstats[$requestid]['stores']['cachestore_static']['sets'] - $startstats[$requestid]['stores']['cachestore_static']['sets']);
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:99,代码来源:cache_test.php

示例4: get_performance_info


//.........这里部分代码省略.........
                    $details .= "<div class='backtrace'>{$backtrace}</div>";
                }
                $details .= '</div>';
            }
        }
        $info['html'] .= "<span class='includedyuimodules'>Included YUI modules: {$yuicount}</span> ";
        $info['txt'] .= "includedyuimodules: {$yuicount} ";
        $info['html'] .= "<span class='includedjsmodules'>Other JavaScript modules: {$othercount}</span> ";
        $info['txt'] .= "includedjsmodules: {$othercount} ";
        if ($details) {
            $info['html'] .= '<div id="yui-module-debug" class="notifytiny">' . $details . '</div>';
        }
    }
    if (!empty($PERF->logwrites)) {
        $info['logwrites'] = $PERF->logwrites;
        $info['html'] .= '<span class="logwrites">Log DB writes ' . $info['logwrites'] . '</span> ';
        $info['txt'] .= 'logwrites: ' . $info['logwrites'] . ' ';
    }
    $info['dbqueries'] = $DB->perf_get_reads() . '/' . ($DB->perf_get_writes() - $PERF->logwrites);
    $info['html'] .= '<span class="dbqueries">DB reads/writes: ' . $info['dbqueries'] . '</span> ';
    $info['txt'] .= 'db reads/writes: ' . $info['dbqueries'] . ' ';
    if (function_exists('posix_times')) {
        $ptimes = posix_times();
        if (is_array($ptimes)) {
            foreach ($ptimes as $key => $val) {
                $info[$key] = $ptimes[$key] - $PERF->startposixtimes[$key];
            }
            $info['html'] .= "<span class=\"posixtimes\">ticks: {$info['ticks']} user: {$info['utime']} sys: {$info['stime']} cuser: {$info['cutime']} csys: {$info['cstime']}</span> ";
            $info['txt'] .= "ticks: {$info['ticks']} user: {$info['utime']} sys: {$info['stime']} cuser: {$info['cutime']} csys: {$info['cstime']} ";
        }
    }
    // Grab the load average for the last minute.
    // /proc will only work under some linux configurations
    // while uptime is there under MacOSX/Darwin and other unices.
    if (is_readable('/proc/loadavg') && ($loadavg = @file('/proc/loadavg'))) {
        list($serverload) = explode(' ', $loadavg[0]);
        unset($loadavg);
    } else {
        if (function_exists('is_executable') && is_executable('/usr/bin/uptime') && ($loadavg = `/usr/bin/uptime`)) {
            if (preg_match('/load averages?: (\\d+[\\.,:]\\d+)/', $loadavg, $matches)) {
                $serverload = $matches[1];
            } else {
                trigger_error('Could not parse uptime output!');
            }
        }
    }
    if (!empty($serverload)) {
        $info['serverload'] = $serverload;
        $info['html'] .= '<span class="serverload">Load average: ' . $info['serverload'] . '</span> ';
        $info['txt'] .= "serverload: {$info['serverload']} ";
    }
    // Display size of session if session started.
    if ($si = \core\session\manager::get_performance_info()) {
        $info['sessionsize'] = $si['size'];
        $info['html'] .= $si['html'];
        $info['txt'] .= $si['txt'];
    }
    if ($stats = cache_helper::get_stats()) {
        $html = '<span class="cachesused">';
        $html .= '<span class="cache-stats-heading">Caches used (hits/misses/sets)</span>';
        $text = 'Caches used (hits/misses/sets): ';
        $hits = 0;
        $misses = 0;
        $sets = 0;
        foreach ($stats as $definition => $stores) {
            $html .= '<span class="cache-definition-stats">';
            $html .= '<span class="cache-definition-stats-heading">' . $definition . '</span>';
            $text .= "{$definition} {";
            foreach ($stores as $store => $data) {
                $hits += $data['hits'];
                $misses += $data['misses'];
                $sets += $data['sets'];
                if ($data['hits'] == 0 and $data['misses'] > 0) {
                    $cachestoreclass = 'nohits';
                } else {
                    if ($data['hits'] < $data['misses']) {
                        $cachestoreclass = 'lowhits';
                    } else {
                        $cachestoreclass = 'hihits';
                    }
                }
                $text .= "{$store}({$data['hits']}/{$data['misses']}/{$data['sets']}) ";
                $html .= "<span class=\"cache-store-stats {$cachestoreclass}\">{$store}: {$data['hits']} / {$data['misses']} / {$data['sets']}</span>";
            }
            $html .= '</span>';
            $text .= '} ';
        }
        $html .= "<span class='cache-total-stats'>Total: {$hits} / {$misses} / {$sets}</span>";
        $html .= '</span> ';
        $info['cachesused'] = "{$hits} / {$misses} / {$sets}";
        $info['html'] .= $html;
        $info['txt'] .= $text . '. ';
    } else {
        $info['cachesused'] = '0 / 0 / 0';
        $info['html'] .= '<span class="cachesused">Caches used (hits/misses/sets): 0/0/0</span>';
        $info['txt'] .= 'Caches used (hits/misses/sets): 0/0/0 ';
    }
    $info['html'] = '<div class="performanceinfo siteinfo">' . $info['html'] . '</div>';
    return $info;
}
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:101,代码来源:moodlelib.php

示例5: get_performance_info


//.........这里部分代码省略.........
             }
         }
         $info['html'] .= "<span class='includedyuimodules'>Included YUI modules: $yuicount</span> ";
         $info['txt'] .= "includedyuimodules: $yuicount ";
         $info['html'] .= "<span class='includedjsmodules'>Other JavaScript modules: $othercount</span> ";
         $info['txt'] .= "includedjsmodules: $othercount ";
         if ($details) {
             $info['html'] .= '<div id="yui-module-debug" class="notifytiny">'.$details.'</div>';
         }
     }

    if (!empty($PERF->logwrites)) {
        $info['logwrites'] = $PERF->logwrites;
        $info['html'] .= '<span class="logwrites">Log DB writes '.$info['logwrites'].'</span> ';
        $info['txt'] .= 'logwrites: '.$info['logwrites'].' ';
    }

    $info['dbqueries'] = $DB->perf_get_reads().'/'.($DB->perf_get_writes() - $PERF->logwrites);
    $info['html'] .= '<span class="dbqueries">DB reads/writes: '.$info['dbqueries'].'</span> ';
    $info['txt'] .= 'db reads/writes: '.$info['dbqueries'].' ';

    if (function_exists('posix_times')) {
        $ptimes = posix_times();
        if (is_array($ptimes)) {
            foreach ($ptimes as $key => $val) {
                $info[$key] = $ptimes[$key] -  $PERF->startposixtimes[$key];
            }
            $info['html'] .= "<span class=\"posixtimes\">ticks: $info[ticks] user: $info[utime] sys: $info[stime] cuser: $info[cutime] csys: $info[cstime]</span> ";
            $info['txt'] .= "ticks: $info[ticks] user: $info[utime] sys: $info[stime] cuser: $info[cutime] csys: $info[cstime] ";
        }
    }

    // Grab the load average for the last minute
    // /proc will only work under some linux configurations
    // while uptime is there under MacOSX/Darwin and other unices
    if (is_readable('/proc/loadavg') && $loadavg = @file('/proc/loadavg')) {
        list($server_load) = explode(' ', $loadavg[0]);
        unset($loadavg);
    } else if ( function_exists('is_executable') && is_executable('/usr/bin/uptime') && $loadavg = `/usr/bin/uptime` ) {
        if (preg_match('/load averages?: (\d+[\.,:]\d+)/', $loadavg, $matches)) {
            $server_load = $matches[1];
        } else {
            trigger_error('Could not parse uptime output!');
        }
    }
    if (!empty($server_load)) {
        $info['serverload'] = $server_load;
        $info['html'] .= '<span class="serverload">Load average: '.$info['serverload'].'</span> ';
        $info['txt'] .= "serverload: {$info['serverload']} ";
    }

    // Display size of session if session started
    if (session_id()) {
        $info['sessionsize'] = display_size(strlen(session_encode()));
        $info['html'] .= '<span class="sessionsize">Session: ' . $info['sessionsize'] . '</span> ';
        $info['txt'] .= "Session: {$info['sessionsize']} ";
    }

/*    if (isset($rcache->hits) && isset($rcache->misses)) {
        $info['rcachehits'] = $rcache->hits;
        $info['rcachemisses'] = $rcache->misses;
        $info['html'] .= '<span class="rcache">Record cache hit/miss ratio : '.
            "{$rcache->hits}/{$rcache->misses}</span> ";
        $info['txt'] .= 'rcache: '.
            "{$rcache->hits}/{$rcache->misses} ";
    }*/

    if ($stats = cache_helper::get_stats()) {
        $html = '<span class="cachesused">';
        $html .= '<span class="cache-stats-heading">Caches interaction by definition then store</span>';
        $text = 'Caches used (hits/misses/sets): ';
        $hits = 0;
        $misses = 0;
        $sets = 0;
        foreach ($stats as $definition => $stores) {
            $html .= '<span class="cache-definition-stats">'.$definition.'</span>';
            $text .= "$definition {";
            foreach ($stores as $store => $data) {
                $hits += $data['hits'];
                $misses += $data['misses'];
                $sets += $data['sets'];
                $text .= "$store($data[hits]/$data[misses]/$data[sets]) ";
                $html .= "<span class='cache-store-stats'>$store: $data[hits] / $data[misses] / $data[sets]</span>";
            }
            $text .= '} ';
        }
        $html .= "<span class='cache-total-stats'>Total Hits / Misses / Sets : $hits / $misses / $sets</span>";
        $html .= '</span> ';
        $info['cachesused'] = "$hits / $misses / $sets";
        $info['html'] .= $html;
        $info['txt'] .= $text.'. ';
    } else {
        $info['cachesused'] = '0 / 0 / 0';
        $info['html'] .= '<span class="cachesused">Caches used (hits/misses/sets): 0/0/0</span>';
        $info['txt'] .= 'Caches used (hits/misses/sets): 0/0/0 ';
    }

    $info['html'] = '<div class="performanceinfo siteinfo">'.$info['html'].'</div>';
    return $info;
}
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:101,代码来源:moodlelib.php


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