本文整理汇总了PHP中memory_get_peak_usage函数的典型用法代码示例。如果您正苦于以下问题:PHP memory_get_peak_usage函数的具体用法?PHP memory_get_peak_usage怎么用?PHP memory_get_peak_usage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了memory_get_peak_usage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
public static function run($r)
{
$commands = array('detailed_system_info' => null, 'list_available_tests' => null, 'list_available_suites' => null, 'info' => array('xonotic'), 'clone_openbenchmarking_result' => array('1107247-LI-MESACOMMI48'), 'result_file_to_text' => array('1107247-LI-MESACOMMI48'), 'diagnostics' => null, 'dump_possible_options' => null);
$individual_times = array();
phodevi::clear_cache();
$start = microtime(true);
foreach ($commands as $command => $args) {
echo PHP_EOL . '### ' . $command . ' ###' . PHP_EOL;
$individual_times[$command] = array();
for ($i = 0; $i < 3; $i++) {
$c_start = microtime(true);
pts_client::execute_command($command, $args);
$c_finish = microtime(true);
array_push($individual_times[$command], $c_finish - $c_start);
}
}
$finish = microtime(true);
echo PHP_EOL . PHP_EOL . '### OVERALL DATA ###' . PHP_EOL . PHP_EOL;
echo 'PHP: ' . PTS_PHP_VERSION . PHP_EOL;
$longest_c = max(array_map('strlen', array_keys($individual_times)));
foreach ($individual_times as $component => $times) {
echo strtoupper($component) . ': ' . str_repeat(' ', $longest_c - strlen($component)) . pts_math::set_precision(round(array_sum($times) / count($times), 3), 3) . ' seconds' . PHP_EOL;
}
echo PHP_EOL . 'ELAPSED TIME: ' . str_repeat(' ', $longest_c - strlen('ELAPSED TIME')) . round($finish - $start, 3) . ' seconds';
echo PHP_EOL . 'PEAK MEMORY USAGE: ' . str_repeat(' ', $longest_c - strlen('PEAK MEMORY USAGE')) . round(memory_get_peak_usage(true) / 1048576, 3) . ' MB';
echo PHP_EOL . 'PEAK MEMORY USAGE (emalloc): ' . str_repeat(' ', $longest_c - strlen('PEAK MEMORY USAGE (emalloc)')) . round(memory_get_peak_usage() / 1048576, 3) . ' MB';
echo PHP_EOL;
}
开发者ID:pchiruma,项目名称:phoronix-test-suite,代码行数:28,代码来源:debug_self_test.php
示例2: measure
/** Allows you to time things and get memory usage
@param name the name of the measure to be printed out with results. To get the timing between events, the name should be the same.
*/
static function measure($name = 'std')
{
$next = count(self::$measures[$name]);
self::$measures[$name][$next]['time'] = microtime(true);
self::$measures[$name][$next]['mem'] = memory_get_usage();
self::$measures[$name][$next]['peakMem'] = memory_get_peak_usage();
}
开发者ID:jstacoder,项目名称:brushfire,代码行数:10,代码来源:Debug.php
示例3: lib_peak_memory
function lib_peak_memory()
{
$oneMb = 1024 * 1024;
$memory = memory_get_peak_usage() / $oneMb;
$memory = round($memory, 4);
return floatval($memory);
}
开发者ID:kennyma,项目名称:Jolt,代码行数:7,代码来源:Common.php
示例4: __invoke
/**
* @param array $record
* @return array
*/
public function __invoke(array $record)
{
$bytes = memory_get_peak_usage($this->realUsage);
$formatted = $this->formatBytes($bytes);
$record['extra'] = array_merge($record['extra'], array('memory_peak_usage' => $formatted));
return $record;
}
开发者ID:nstanard,项目名称:webpagetest,代码行数:11,代码来源:MemoryPeakUsageProcessor.php
示例5: getEndingNotes
/**
* Get ending notes
*
* @param array $writers
*/
function getEndingNotes($writers)
{
$result = '';
// Do not show execution time for index
if (!IS_INDEX) {
$result .= date('H:i:s') . " Done writing file(s)" . EOL;
$result .= date('H:i:s') . " Peak memory usage: " . memory_get_peak_usage(true) / 1024 / 1024 . " MB" . EOL;
}
// Return
if (CLI) {
$result .= 'The results are stored in the "results" subdirectory.' . EOL;
} else {
if (!IS_INDEX) {
$types = array_values($writers);
$result .= '<p> </p>';
$result .= '<p>Results: ';
foreach ($types as $type) {
if (!is_null($type)) {
$resultFile = 'results/' . SCRIPT_FILENAME . '.' . $type;
if (file_exists($resultFile)) {
$result .= "<a href='{$resultFile}' class='btn btn-primary'>{$type}</a> ";
}
}
}
$result .= '</p>';
}
}
return $result;
}
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:34,代码来源:Sample_Header.php
示例6: paintFooter
/**
* Paints the end of the test with a summary of
* the passes and failures.
*
* @param PHPUnit_Framework_TestResult $result Result object
*
* @return void
*/
public function paintFooter($result)
{
ob_end_flush();
$colour = $result->failureCount() + $result->errorCount() > 0 ? "red" : "green";
echo "</ul>\n";
echo "<div style=\"";
echo "padding: 8px; margin: 1em 0; background-color: {$colour}; color: white;";
echo "\">";
echo $result->count() - $result->skippedCount() . "/" . $result->count();
echo " test methods complete:\n";
echo "<strong>" . count($result->passed()) . "</strong> passes, ";
echo "<strong>" . $result->failureCount() . "</strong> fails, ";
echo "<strong>" . $this->numAssertions . "</strong> assertions and ";
echo "<strong>" . $result->errorCount() . "</strong> exceptions.";
echo "</div>\n";
echo '<div style="padding:0 0 5px;">';
echo '<p><strong>Time:</strong> ' . $result->time() . ' seconds</p>';
echo '<p><strong>Peak memory:</strong> ' . number_format(memory_get_peak_usage()) . ' bytes</p>';
echo $this->_paintLinks();
echo '</div>';
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
$coverage = $result->getCodeCoverage();
if (method_exists($coverage, 'getSummary')) {
$report = $coverage->getSummary();
echo $this->paintCoverage($report);
}
if (method_exists($coverage, 'getData')) {
$report = $coverage->getData();
echo $this->paintCoverage($report);
}
}
$this->paintDocumentEnd();
}
开发者ID:Marcin11,项目名称:_mojePanstwo-Portal,代码行数:41,代码来源:CakeHtmlReporter.php
示例7: debugHelper
public function debugHelper()
{
echo "<pre>";
echo "<b>Kajona V4 Debug Subsystem</b>\n\n";
if (getGet("debugfile") != "") {
echo "Loading path for " . getGet("debugfile") . "\n";
$strPath = array_search(getGet("debugfile"), class_resourceloader::getInstance()->getFolderContent("/debug", array(".php")));
if ($strPath !== false) {
echo "Passing request to " . $strPath . "\n\n";
include _realpath_ . $strPath;
}
} else {
echo "Searching for debug-scripts available...\n";
$arrFiles = class_resourceloader::getInstance()->getFolderContent("/debug", array(".php"));
echo "<ul>";
foreach ($arrFiles as $strPath => $strOneFile) {
echo "<li><a href='?debugfile=" . $strOneFile . "' >" . $strOneFile . "</a> <br />" . $strPath . "</li>";
}
echo "</ul>";
}
$arrTimestampEnde = gettimeofday();
$intTimeUsed = ($arrTimestampEnde['sec'] * 1000000 + $arrTimestampEnde['usec'] - ($this->arrTimestampStart['sec'] * 1000000 + $this->arrTimestampStart['usec'])) / 1000000;
echo "\n\n<b>PHP-Time:</b> " . number_format($intTimeUsed, 6) . " sec \n";
echo "<b>Queries db/cachesize/cached/fired:</b> " . class_carrier::getInstance()->getObjDB()->getNumber() . "/" . class_carrier::getInstance()->getObjDB()->getCacheSize() . "/" . class_carrier::getInstance()->getObjDB()->getNumberCache() . "/" . (class_carrier::getInstance()->getObjDB()->getNumber() - class_carrier::getInstance()->getObjDB()->getNumberCache()) . "\n";
echo "<b>Templates cached:</b> " . class_carrier::getInstance()->getObjTemplate()->getNumberCacheSize() . " \n";
echo "<b>Memory/Max Memory:</b> " . bytesToString(memory_get_usage()) . "/" . bytesToString(memory_get_peak_usage()) . " \n";
echo "<b>Classes Loaded:</b> " . class_classloader::getInstance()->getIntNumberOfClassesLoaded() . " \n";
echo "<b>Cache requests/hits/saves/cachesize:</b> " . class_cache::getIntRequests() . "/" . class_cache::getIntHits() . "/" . class_cache::getIntSaves() . "/" . class_cache::getIntCachesize() . " \n";
echo "</pre>";
}
开发者ID:jinshana,项目名称:kajonacms,代码行数:30,代码来源:debug.php
示例8: process
public function process()
{
$this->data['time_taken'] = self::timer_stop_float();
$this->data['time_limit'] = ini_get('max_execution_time');
$this->data['time_start'] = $GLOBALS['timestart'];
if (!empty($this->data['time_limit'])) {
$this->data['time_usage'] = 100 / $this->data['time_limit'] * $this->data['time_taken'];
} else {
$this->data['time_usage'] = 0;
}
if (function_exists('memory_get_peak_usage')) {
$this->data['memory'] = memory_get_peak_usage();
} else {
if (function_exists('memory_get_usage')) {
$this->data['memory'] = memory_get_usage();
} else {
$this->data['memory'] = 0;
}
}
if (is_user_logged_in()) {
$this->data['current_user'] = self::format_user(wp_get_current_user());
} else {
$this->data['current_user'] = false;
}
if (function_exists('current_user_switched') && current_user_switched()) {
$this->data['switched_user'] = self::format_user(current_user_switched());
} else {
$this->data['switched_user'] = false;
}
$this->data['memory_limit'] = QM_Util::convert_hr_to_bytes(ini_get('memory_limit'));
$this->data['memory_usage'] = 100 / $this->data['memory_limit'] * $this->data['memory'];
$this->data['is_admin'] = is_admin();
}
开发者ID:johnbillion,项目名称:query-monitor,代码行数:33,代码来源:overview.php
示例9: make_stats
/**
* method make_stats
* param
* return builds the statistics
*/
public static function make_stats()
{
// INITIAL TIME
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
self::$time = time();
// INITIAL MEMORY
$result['initial_memory'] = array(round(memory_get_usage() / 1024, 1), round(memory_get_usage(1) / 1024, 1));
// MAKE STATISTICS FOR USERS
self::make_user_rank();
// MAKE STATISTICS FOR ALLIANCE
self::make_ally_rank();
// END STATISTICS BUILD
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$result['stats_time'] = self::$time;
$result['totaltime'] = $endtime - $starttime;
$result['memory_peak'] = array(round(memory_get_peak_usage() / 1024, 1), round(memory_get_peak_usage(1) / 1024, 1));
$result['end_memory'] = array(round(memory_get_usage() / 1024, 1), round(memory_get_usage(1) / 1024, 1));
return $result;
}
开发者ID:Gritch69,项目名称:XG-Project,代码行数:30,代码来源:Statistics_Lib.php
示例10: render
/**
*
* render DebugInfo
* @return string
*/
public function render()
{
if ($this->isDisabled()) {
return;
}
$this->isDisabled = true;
$this->timerEnd(self::START_APP);
$this->memoryEnd(self::START_APP);
$output = '';
//Timer
$output .= '<h4>Timer</h4>';
foreach ($this->debug['timer'] as $timer) {
$output .= $timer . '<br/>';
}
//SQL
$output .= '<h4>SQL</h4>';
$output .= '<table>';
foreach ($this->debug['sql'] as $sql) {
$output .= sprintf('<tr><td>%s</td><td>%d</td><td>%.2f</td></tr>', $sql[0], $sql[1], $sql[2]);
}
$output .= '</table>';
//Memory
$output .= '<h4>Memory</h4>';
$output .= 'Пик использования памяти: ' . round(memory_get_peak_usage() / 1000, 0) . ' Кб<br/>';
foreach ($this->debug['memory'] as $memory) {
$output .= $memory . '<br/>';
}
return $output;
}
开发者ID:ntcnhjdobr,项目名称:simpleSite,代码行数:34,代码来源:Debugger.php
示例11: flush
/**
* 格納されたログを出力する
*/
public static final function flush()
{
if (self::isPublishLevel() >= 4) {
self::$LOG[] = new self(4, "use memory: " . number_format(memory_get_usage()) . "byte / " . number_format(memory_get_peak_usage()) . "byte");
self::$LOG[] = new self(4, sprintf("------- end logger ( %f sec ) ------- ", microtime(true) - (double) self::$START));
}
if (!empty(self::$LOG)) {
$level = array("none", "error", "warning", "info", "debug");
foreach (self::$LOG as $log) {
$value = $log->value();
if (Rhaco::def("core.Log@expression") === true) {
ob_start();
var_dump($value);
$value = substr(ob_get_clean(), 0, -1);
}
$value = "[" . $level[$log->level()] . " " . $log->time() . "]:[" . $log->file() . ":" . $log->line() . "] " . $value . "\n";
if (self::$DISP_LEVEL >= $log->level() && self::$DISP) {
print $value;
}
if (self::$FILE_LEVEL >= $log->level()) {
if (empty(self::$PATH)) {
throw new Exception("not found path");
}
File::append(sprintf("%s/%s.log", File::path(self::$PATH), date("Ymd")), $value);
}
self::call_filter($level[$log->level()], $log);
}
self::call_filter("flush", self::$LOG);
}
self::$LOG = array();
}
开发者ID:hisaboh,项目名称:w2t,代码行数:34,代码来源:Log.php
示例12: statisticsEnd
/**
* Stop and output statistics
*
* @param string $name
*/
public function statisticsEnd($name)
{
$this->hr();
$this->out('Took: ' . $this->_startTime[$name]->diff(new DateTime())->format('%ad %hh %im %ss'));
$this->out('Memory: ' . sprintf('%0.3f', memory_get_peak_usage(true) / (1024 * 1024)) . "Mb max used");
$this->hr();
}
开发者ID:imsamurai,项目名称:cakephp-advancedshell,代码行数:12,代码来源:AdvancedShell.php
示例13: mark
/**
* Mark profile system's information
*
* @return mixed
*/
public function mark()
{
$currentMem = memory_get_usage() / 1048576;
$mark = ['memory_MB' => $currentMem, 'next_memory_MB' => $currentMem - $this->_prevMemory, 'memory_get_usage' => memory_get_usage(), 'memory_get_peak_usage' => memory_get_peak_usage()];
$this->_prevMemory = $currentMem;
return $mark;
}
开发者ID:tronghieu,项目名称:flywheel-framework,代码行数:12,代码来源:MemoryResource.php
示例14: index
public function index()
{
// auth
if (!$this->cron) {
Util\Auth::isAdminAuthorized($this->app->user(), 'admin.dev', false, '/');
}
$this->log('start');
$options = [];
$options['where'][] = 'cron.active = 1';
$options['order'][] = 'cron.display_order';
$crons = \Own\Bus\Cron\Data::loadAll($options);
foreach ($crons as $cron) {
$notExpired = $cron->getLastRun()->add(new \DateInterval('PT' . $cron->getSchedule() . 'M')) > new Util\DateTime();
if ($this->cron && $notExpired) {
continue;
}
if ($cron->getMethod() != 'match' && $notExpired) {
continue;
}
if (!$this->cron && $this->app->timer() > 25) {
break;
}
$cron->setLastRun(date('Y-m-d H:i:s'));
$cron->save();
$method = $cron->getMethod();
$this->{$method}();
}
$message = $this->app->timer() . 's,
' . $this->app->queryCount() . ' queries,
' . round(memory_get_peak_usage() / 1024) . ' kb';
$this->log($message);
}
开发者ID:vincium,项目名称:lot,代码行数:32,代码来源:Cron.php
示例15: smarty_function_memusage
function smarty_function_memusage($params, $smarty)
{
if (function_exists('memory_get_peak_usage')) {
// PHP 5.2+
$memusage = memory_get_peak_usage();
} elseif (function_exists('memory_get_usage')) {
//PHP 4 >= 4.3.2, PHP 5
$memusage = memory_get_usage();
} else {
$memusage = 0;
}
if ($memusage > 0) {
$memunit = "B";
if ($memusage > 1024) {
$memusage = $memusage / 1024;
$memunit = "kB";
}
if ($memusage > 1024) {
$memusage = $memusage / 1024;
$memunit = "MB";
}
if ($memusage > 1024) {
$memusage = $memusage / 1024;
$memunit = "GB";
}
print number_format($memusage, 2) . $memunit;
} else {
print tra("Unknown");
}
}
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:30,代码来源:function.memusage.php
示例16: runTests
function runTests($test_obj = null)
{
if (!$test_obj) {
$test_obj = $this;
}
$tested = array();
$data = array();
foreach (get_class_methods($test_obj) as $method) {
$m = '';
if (substr($method, 0, 5) == 'test_') {
$m = substr($method, 5);
} elseif (substr($method, 0, 8) == 'prepare_') {
$m = substr($method, 8);
} else {
continue;
}
// Do not retest same function even if it has both prepare and test
if ($tested[$m]) {
continue;
}
$tested[$m] = true;
// Row contains test result data
$row = array('name' => $m, 'id' => $m);
foreach ($this->variances as $key => $vari) {
if (is_numeric($key)) {
$key = $vari;
}
// Input is a result of preparation function
if (method_exists($test_obj, 'prepare_' . $m)) {
$input = $test_obj->{'prepare_' . $m}($vari, $method);
} else {
$input = $test_obj->prepare($vari, $method);
}
$this->input = $input;
$test_func = method_exists($test_obj, 'test_' . $m) ? 'test_' . $m : 'test';
// Test speed
$me = memory_get_peak_usage();
$ms = microtime(true);
/*
$limit=20;$hl=round($limit /2);
for($i=0;$i<$limit;$i++){
//$result=call_user_func_array(array($test_obj,$test_func),$input);
*/
$result = (string) $test_obj->{$test_func}($input[0], $input[1]);
//$this->$method($vari);
/*
if($i==$hl){
$meh=memory_get_peak_usage();
}
*/
//}
$ms = microtime(true) - $ms;
$me = ($mend = memory_get_peak_usage()) - $me;
$row[$key . '_inf'] = 'Speed: ' . round($ms, 3) . '<br/>Memory: ' . $me;
$this->formatResult($row, $key, $result);
}
$data[] = $row;
}
$this->grid->setStaticSource($data);
}
开发者ID:respond,项目名称:atk4,代码行数:60,代码来源:Tester.php
示例17: gatherMemoryData
public function gatherMemoryData()
{
$memoryTotals = array();
$memoryTotals['used'] = $this->getReadableFileSize(memory_get_peak_usage());
$memoryTotals['total'] = ini_get("memory_limit");
$this->output['memoryTotals'] = $memoryTotals;
}
开发者ID:SainsburysTests,项目名称:sainsburys,代码行数:7,代码来源:phpquickprofiler.php
示例18: ob_show_and_log
function ob_show_and_log($type)
{
$log =& Log::singleton('file', USERBASE . 'log.txt', $type, array('locking' => true, 'timeFormat' => '%Y-%m-%d %H:%M:%S'));
$length = $GLOBALS['filesize'];
$num_queries = isset($GLOBALS['db']) ? $GLOBALS['db']->num_queries : 0;
switch ($type) {
case 'file':
// {
$location = $_SERVER['REQUEST_URI'];
break;
// }
// }
case 'menu':
// {
$location = 'menu';
break;
// }
// }
case 'page':
// {
$location = $GLOBALS['PAGEDATA']->id . '|' . $GLOBALS['PAGEDATA']->getRelativeUrl();
break;
// }
// }
default:
// {
$location = 'unknown_type_' . $type;
//}
}
$log->log($_SERVER['REMOTE_ADDR'] . ' ' . $location . ' ' . $_SERVER['HTTP_USER_AGENT'] . ' ' . $_SERVER['HTTP_REFERER'] . ' ' . memory_get_peak_usage() . ' ' . $length . ' ' . (microtime(true) - START_TIME) . ' ' . $num_queries);
ob_flush();
}
开发者ID:AmandaSyachri,项目名称:webworks-webme,代码行数:32,代码来源:log_retrieved_file.php
示例19: init
protected function init()
{
try {
$this->data['timestamp'] = time();
$this->data['direction'] = waRequest::post('direction', 'import');
$type_model = new shopTypeModel();
$this->data['types'] = array_map('intval', array_keys($type_model->getTypes()));
switch ($this->data['direction']) {
case 'export':
$this->initExport();
break;
case 'import':
default:
$this->data['direction'] = 'import';
$this->initImport();
break;
}
$stages = array_keys($this->data['count']);
$this->data['current'] = array_fill_keys($stages, 0);
$value = $this->data['direction'] == 'import' ? $this->emulate(null) ? array('add' => 0, 'found' => 0, 'skip' => 0, 'rights' => 0, 'currency' => 0) : array('new' => 0, 'update' => 0, 'skip' => 0, 'error' => 0, 'rights' => 0, 'currency' => 0) : 0;
$this->data['processed_count'] = array_fill_keys($stages, $value);
$this->data['map'] = array();
$this->data['memory'] = memory_get_peak_usage();
$this->data['memory_avg'] = memory_get_usage();
$this->data['timestamp'] = time();
} catch (waException $ex) {
$this->error($ex->getMessage());
echo $this->json(array('error' => $ex->getMessage()));
exit;
}
}
开发者ID:Lazary,项目名称:webasyst,代码行数:31,代码来源:shopCsvProductrun.controller.php
示例20: __invoke
public function __invoke(Context $context, $next)
{
$start = microtime(true);
$next($context);
$time = (microtime(true) - $start) * 1000;
$context->withHeader('X-Profiler-Response-Time', sprintf('%0.4f ms', $time))->withHeader('X-Profiler-Memory-Usage', sprintf('%0.2fkB', memory_get_usage() / 1024))->withHeader('X-Profiler-Peak-Memory-Usage', sprintf('%0.2fkB', memory_get_peak_usage() / 1024));
}
开发者ID:reekoheek,项目名称:docker-reverseproxy,代码行数:7,代码来源:Profiler.php
注:本文中的memory_get_peak_usage函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论