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;
 }
Пример #2
0
 /** 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();
 }
Пример #3
0
function lib_peak_memory()
{
    $oneMb = 1024 * 1024;
    $memory = memory_get_peak_usage() / $oneMb;
    $memory = round($memory, 4);
    return floatval($memory);
}
 /**
  * @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;
 }
Пример #5
0
/**
 * 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>&nbsp;</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;
}
 /**
  * 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();
 }
Пример #7
0
 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>";
 }
Пример #8
0
 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();
 }
Пример #9
0
 /**
  * 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;
 }
Пример #10
0
 /**
  * 
  * 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;
 }
Пример #11
0
 /**
  * 格納されたログを出力する
  */
 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();
 }
 /**
  * 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();
 }
 /**
  * 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;
 }
Пример #14
0
 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);
 }
Пример #15
0
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");
    }
}
Пример #16
0
 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);
 }
 public function gatherMemoryData()
 {
     $memoryTotals = array();
     $memoryTotals['used'] = $this->getReadableFileSize(memory_get_peak_usage());
     $memoryTotals['total'] = ini_get("memory_limit");
     $this->output['memoryTotals'] = $memoryTotals;
 }
 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();
 }
 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;
     }
 }
Пример #20
0
 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));
 }
 private function prepareData($context)
 {
     $c = ++$this->local_storage['counter'];
     $m = memory_get_usage();
     $p = memory_get_peak_usage();
     if ($p > $this->local_storage['prev_memory_peak']) {
         $this->local_storage['prev_memory_peak'] = $p;
         $this->local_storage['memory_peak_counter'] = $c;
     }
     $buffer = '<pre>';
     $buffer .= 'Hello world! #' . $c . "\n";
     $buffer .= 'Memory usage: ' . $m . "\n";
     $buffer .= 'Peak Memory usage: ' . $p . "\n";
     $buffer .= 'Memory usage last grew at request#' . $this->local_storage['memory_peak_counter'] . "\n\n";
     $buffer .= "HEADERS:\n" . var_export($context['env'], true) . "\n";
     $buffer .= "COOKIES:\n" . var_export($context['_COOKIE']->__toArray(), true) . "\n";
     $buffer .= "GET:\n" . var_export($context['_GET'], true) . "\n";
     if ($context['env']['REQUEST_METHOD'] === 'POST') {
         $buffer .= "POST:\n" . var_export($context['_POST'], true) . "\n";
         $buffer .= "FILES:\n" . var_export($context['_FILES'], true) . "\n";
     } elseif (!in_array($context['env']['REQUEST_METHOD'], array('GET', 'HEAD'))) {
         $buffer .= "BODY:\n" . var_export(stream_get_contents($context['stdin']), true) . "\n";
     }
     $buffer .= '</pre>';
     return $buffer;
 }
Пример #22
0
 private function stopMemoryCounter()
 {
     $this->stopMemory = memory_get_usage();
     $this->peakMemory = memory_get_peak_usage();
     $this->memory = $this->peakMemory - $this->startMemory;
     return $this;
 }
Пример #23
0
 /**
  * format memory usage
  *
  * @return string
  */
 public function formatMemoryUsage()
 {
     $sLog = '';
     if (function_exists('memory_get_usage')) {
         $iKb = (int) (memory_get_usage() / 1024);
         $iMb = round($iKb / 1024, 3);
         $sLog .= 'Memory usage: ' . $iMb . ' MB';
         if (function_exists('memory_get_peak_usage')) {
             $iPeakKb = (int) (memory_get_peak_usage() / 1024);
             $iPeakMb = round($iPeakKb / 1024, 3);
             $sLog .= ' (peak: ' . $iPeakMb . ' MB)';
         }
         $sLog .= '<br />';
         if (version_compare(PHP_VERSION, '5.2.0', '>=')) {
             $iKb = (int) (memory_get_usage(true) / 1024);
             $iMb = round($iKb / 1024, 3);
             $sLog .= 'System memory usage: ' . $iMb . ' MB';
             if (function_exists('memory_get_peak_usage')) {
                 $iPeakKb = (int) (memory_get_peak_usage(true) / 1024);
                 $iPeakMb = round($iPeakKb / 1024, 3);
                 $sLog .= ' (peak: ' . $iPeakMb . ' MB)';
             }
             $sLog .= '<br />';
         }
     }
     return $sLog;
 }
Пример #24
0
 public function backup_status()
 {
     // Make sure the serial exists.
     if (pb_backupbuddy::_POST('serial') == '' || empty(pb_backupbuddy::$options['backups'][$_POST['serial']])) {
         echo '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|0|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|error|~|Error #5445589. Invalid backup serial (' . htmlentities(pb_backupbuddy::_POST('serial')) . '). Please check directory permissions and your PHP error_log as an early backup function (such as pre_backup) may have failed. Fatal error.' . "\n";
         echo '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|0|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|action|~|halt_script' . "\n";
     } else {
         // Return the status information since last retrieval.
         $return_status = '!' . pb_backupbuddy::$format->localize_time(time()) . "|~|0|~|0|~|ping\n";
         //error_log( print_r( pb_backupbuddy::$options['backups'], true ) );
         foreach (pb_backupbuddy::$options['backups'][$_POST['serial']]['steps'] as $step) {
             if ($step['start_time'] != 0 && $step['finish_time'] == 0) {
                 // A step has begun but has not finished. This should not happen but the WP cron is funky. Wait a while before continuing.
                 pb_backupbuddy::status('details', 'Waiting for function `' . $step['function'] . '` to complete. Started ' . (time() - $step['start_time']) . ' seconds ago.', $_POST['serial']);
                 if (time() - $step['start_time'] > 300) {
                     pb_backupbuddy::status('warning', 'The function `' . $step['function'] . '` is taking an abnormally long time to complete (' . (time() - $step['start_time']) . ' seconds). The backup may have stalled.', $_POST['serial']);
                 }
             } elseif ($step['start_time'] == 0) {
                 // Step that has not started yet.
             } else {
                 // Last case: Finished. Skip.
                 // Do nothing.
             }
         }
         /********** Begin file sizes for status updates. *********/
         $temporary_zip_directory = pb_backupbuddy::$options['backup_directory'] . 'temp_zip_' . $_POST['serial'] . '/';
         if (file_exists($temporary_zip_directory)) {
             // Temp zip file.
             $directory = opendir($temporary_zip_directory);
             while ($file = readdir($directory)) {
                 if ($file != '.' && $file != '..') {
                     $stats = stat($temporary_zip_directory . $file);
                     $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|details|~|' . __('Temporary ZIP file size', 'it-l10n-backupbuddy') . ': ' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
                     $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
                 }
             }
             closedir($directory);
             unset($directory);
         }
         if (file_exists(pb_backupbuddy::$options['backups'][$_POST['serial']]['archive_file'])) {
             // Final zip file.
             $stats = stat(pb_backupbuddy::$options['backups'][$_POST['serial']]['archive_file']);
             $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|details|~|' . __('Final ZIP file size', 'it-l10n-backupbuddy') . ': ' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
             $return_status .= '!' . pb_backupbuddy::$format->localize_time(time()) . '|~|' . round(microtime(true) - pb_backupbuddy::$start_time, 2) . '|~|' . round(memory_get_peak_usage() / 1048576, 2) . '|~|action|~|archive_size^' . pb_backupbuddy::$format->file_size($stats['size']) . "\n";
         }
         /********** End file sizes for status updates. *********/
         $status_lines = pb_backupbuddy::get_status(pb_backupbuddy::_POST('serial'), true, false, true);
         // Clear file, dont unlink file (pclzip cant handle files unlinking mid-zip), dont show getting status message.
         if ($status_lines !== false) {
             // Only add lines if there is status contents.
             foreach ($status_lines as $status_line) {
                 //$return_status .= '!' . $status_line[0] . '|' . $status_line[3] . '|' . $status_line[4] . '( ' . $status_line[1] . 'secs / ' . $status_line[2] . 'MB )' . "\n";
                 $return_status .= '!' . implode('|~|', $status_line) . "\n";
             }
         }
         // Return messages.
         echo $return_status;
     }
     die;
 }
Пример #25
0
function uvc_plugin_activate()
{
    update_option('ultimate_vc_addons_redirect', true);
    $memory = ini_get('memory_limit');
    $allowed_memory = preg_replace("/[^0-9]/", "", $memory) * 1024 * 1024;
    $peak_memory = memory_get_peak_usage(true);
    if ($allowed_memory - $peak_memory <= 14436352) {
        $pre = __('Unfortunately, plugin could not be activated. Not enough memory available.', 'ultimate_vc');
        $sub = __('Please contact', 'ultimate_vc');
        trigger_error($pre . ' ' . $sub . ' <a href="https://support.brainstormforce.com/">' . __('plugin support', 'ultimate_vc') . '</a>.', E_USER_ERROR);
    }
    // theme depend custom row class
    $themes = array('X' => 'x-content-band', 'HighendWP' => 'vc_row', 'Vellum' => 'vc_section_wrapper', 'Curves' => 'default-section');
    $site_theme = wp_get_theme();
    $current_theme = $site_theme->get('Name');
    if (array_key_exists($current_theme, $themes)) {
        if (!get_option('ultimate_custom_vc_row') || get_option('ultimate_custom_vc_row') == '') {
            update_option('ultimate_custom_vc_row', $themes[$current_theme]);
        }
    }
    if (!get_option('ultimate_js') || get_option('ultimate_js') == '') {
        update_option('ultimate_js', 'enable');
    }
    if (!get_option('ultimate_css') || get_option('ultimate_css') == '') {
        update_option('ultimate_css', 'enable');
    }
}
/**
 *
 * Adds a piece of commented out code to the source code of each webpage that shows many queries occur, time taken and memory used  
 *
 * @since 4.1.1
 *
 * @param type  $var statisitcs.
 * @param array $args {
 *     @type type $var statistics : var to store the the queries and echo it out to the page 
 * }
 */
function addStatistics()
{
    $statistics = sprintf('%d queries in %.3f seconds, using %.2fMB memory', get_num_queries(), timer_stop(0, 3), memory_get_peak_usage() / 1024 / 1024);
    if (current_user_can('manage_options')) {
        echo "<!-- {$statistics} -->";
    }
}
Пример #27
0
 private function saveDebugInformation(\Exception $ex = null)
 {
     if (!$this->input->hasOption('jms-job-id') || null === ($jobId = $this->input->getOption('jms-job-id'))) {
         return;
     }
     $this->getConnection()->executeUpdate("UPDATE jms_jobs SET stackTrace = :trace, memoryUsage = :memoryUsage, memoryUsageReal = :memoryUsageReal WHERE id = :id", array('id' => $jobId, 'memoryUsage' => memory_get_peak_usage(), 'memoryUsageReal' => memory_get_peak_usage(true), 'trace' => serialize($ex ? FlattenException::create($ex) : null)));
 }
 public function toHtml()
 {
     $topPanel = new TopPanelControl(null, 'debugTopPanel');
     $topPanel->setCaption('
             <div class="debug-block">
                 <span class="glyphicon glyphicon-flash"></span> &nbsp;&nbsp;' . QueryLog::count() . '
             </div>
             <div class="debug-block">
                 <span class="glyphicon glyphicon-time"></span> &nbsp;&nbsp;' . Profiler::getTotalTime() . ' ms
             </div>
             <div class="debug-block">
                 <span class="glyphicon glyphicon-oil"></span> &nbsp;&nbsp;' . round(memory_get_peak_usage() / 1024 / 1024, 1) . ' MB
             </div>
             ')->setOpened(Logging::isError());
     if ($this->mode === self::MODE_LARGE) {
         $tabControl = new TabControl(null, 'debugTabControl');
         $tabControl->addTab('Log (' . count(Logging::getLogItems()) . ')')->add($this->showLog());
         $tabControl->addTab('SQL-Queries (' . QueryLog::count() . ')')->add($this->showQueryLog());
         $tabControl->addTab('Request')->add($this->showNfsRequest());
         $tabControl->addTab('REQUEST-Array (' . count($_REQUEST) . ')')->add($this->showRequest());
         if (Configuration::get('logging.showServerVar') === 'true') {
             $tabControl->addTab('SERVER-Array (' . count($_SERVER) . ')')->add($this->showServer());
         }
         $tabControl->addTab('FILES-Array (' . count($_FILES) . ')')->add($this->showFiles());
         $tabControl->addTab('Profiler')->add($this->showProfilerInfo());
         $tabControl->addTab('Cache')->add($this->showTabInfo());
         $tabControl->addTab('Debug')->add($this->showDebugTab());
         $topPanel->add($tabControl);
     }
     Javascript::addJs($topPanel->getJavascript());
     return $topPanel->toHtml();
 }
Пример #29
0
 /**
  * Execute barebones JSON middleware request
  */
 protected static function executeRequest(Request $request)
 {
     if (testAdapter == 'HTTP') {
         $uri = str_replace('http://localhost', testHttpUri, $request->getUri());
         $response = static::$adapter->send($request, $uri);
         self::$mem = 0;
     } else {
         self::$mem = memory_get_peak_usage();
         $response = self::$app->handle($request);
         self::$mem = memory_get_peak_usage() - self::$mem;
     }
     if (self::$debug) {
         echo "\nRequest: " . ($method = $request->getMethod()) . ' ' . $request->getUri() . "\n";
         if ($method == 'POST') {
             echo "Content: " . $request->getContent() . "\n";
         }
     }
     // always provide normal Response to test cases
     if ($response instanceof StreamedResponse) {
         ob_start();
         $response->sendContent();
         $content = ob_get_contents();
         ob_end_clean();
         $response = Response::create($content, $response->getStatusCode(), $response->headers->all());
     }
     if (self::$debug) {
         echo "\nResponse: " . $response . "\n";
     }
     return $response;
 }
Пример #30
0
function dump_memory($init_size)
{
    $peak = number_format(memory_get_peak_usage() / 1024, 0, '.', ',');
    $curr = number_format(memory_get_usage() / 1024, 0, '.', ',');
    $diff = $curr - $init_size;
    echo 'peak: ' . $peak . ' kb, end: ' . $curr . ' kb, add: ' . $diff . " kb<br>";
}