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


PHP pts_client::terminal_width方法代碼示例

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


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

示例1: string_header

 protected static function string_header($heading, $char = '=')
 {
     // Return a string header
     if (!isset($heading[1])) {
         return null;
     }
     $header_size = 40;
     foreach (explode(PHP_EOL, $heading) as $line) {
         if (isset($line[$header_size + 1])) {
             $header_size = strlen($line);
         }
     }
     if (($terminal_width = pts_client::terminal_width()) < $header_size && $terminal_width > 0) {
         $header_size = $terminal_width;
     }
     return PHP_EOL . str_repeat($char, $header_size) . PHP_EOL . $heading . PHP_EOL . str_repeat($char, $header_size) . PHP_EOL . PHP_EOL;
 }
開發者ID:ShaolongHu,項目名稱:phoronix-test-suite,代碼行數:17,代碼來源:pts_basic_display_mode.php

示例2: test_install_download_file

 public function test_install_download_file($process, &$pts_test_file_download)
 {
     $expected_time = 0;
     $progress_prefix = null;
     switch ($process) {
         case 'DOWNLOAD_FROM_CACHE':
             $process_string = 'Downloading From Cache';
             $progress_prefix = 'Downloading';
             break;
         case 'LINK_FROM_CACHE':
             $process_string = 'Linking From Cache';
             break;
         case 'COPY_FROM_CACHE':
             $process_string = 'Copying From Cache';
             $progress_prefix = 'Copying';
             break;
         case 'FILE_FOUND':
             $process_string = 'File Found';
             break;
         case 'DOWNLOAD':
             $process_string = 'Downloading';
             $progress_prefix = 'Downloading';
             if (($avg_speed = pts_download_speed_manager::get_average_download_speed()) > 0 && ($this_size = $pts_test_file_download->get_filesize()) > 0) {
                 $expected_time = $this_size / $avg_speed;
             }
             break;
     }
     $expected_time = is_numeric($expected_time) && $expected_time > 0 ? pts_strings::format_time($expected_time, 'SECONDS', false, 60) : null;
     // TODO: handle if file-name is too long for terminal width
     $download_string = $this->tab . $this->tab . $process_string . ': ' . $pts_test_file_download->get_filename();
     $download_size_string = $pts_test_file_download->get_filesize() > 0 ? ' [' . self::bytes_to_download_size($pts_test_file_download->get_filesize()) . 'MB]' : null;
     $offset_length = pts_client::terminal_width() > 1 ? pts_client::terminal_width() : pts_test_file_download::$longest_file_name_length;
     $offset_length = $offset_length - strlen($download_string) - strlen($download_size_string) - 2;
     if ($offset_length < 2) {
         $offset_length = 2;
     }
     $download_string .= str_repeat(' ', $offset_length - 2);
     $download_string .= $download_size_string;
     echo $download_string . PHP_EOL;
     $this->progress_line_prefix = $expected_time != null ? 'Estimated Download Time: ' . $expected_time : $progress_prefix;
     $this->progress_last_float = -1;
     $this->progress_tab_count = 2;
     $this->progress_string_length = strlen($download_string);
 }
開發者ID:rkingsbury,項目名稱:phoronix-test-suite,代碼行數:44,代碼來源:pts_websocket_display_mode.php

示例3: run

 public static function run($r)
 {
     pts_client::$display->generic_heading('Available Tests');
     $available_tests = pts_openbenchmarking::available_tests(false);
     $available_suites = pts_openbenchmarking::available_suites(false);
     $test_count = count($available_tests);
     $suite_count = count($available_suites);
     $total_count = $test_count + $suite_count;
     $total_cache_count = 0;
     $total_cache_size = 0;
     if ($test_count == 0 || !pts_network::internet_support_available()) {
         echo PHP_EOL . 'No tests found. Please check that you have Internet connectivity to download test profile data from OpenBenchmarking.org. The Phoronix Test Suite has documentation on configuring the network setup, proxy settings, and PHP network options. Please contact Phoronix Media if you continuing to experience problems.' . PHP_EOL . PHP_EOL;
         return false;
     }
     $terminal_width = pts_client::terminal_width();
     // Cache test profiles
     foreach ($available_tests as $i => $identifier) {
         $repo = substr($identifier, 0, strpos($identifier, '/'));
         $test = substr($identifier, strlen($repo) + 1);
         $repo_index = pts_openbenchmarking::read_repository_index($repo);
         echo $i . '/' . $total_count . ': ' . ($repo_index['tests'][$test]['title'] != null ? $repo_index['tests'][$test]['title'] . ' [' . $repo_index['tests'][$test]['test_type'] . ']' : null) . PHP_EOL;
         foreach ($repo_index['tests'][$test]['versions'] as $version) {
             $qualified_identifier = $repo . '/' . $test . '-' . $version;
             echo $qualified_identifier;
             $success = pts_openbenchmarking::download_test_profile($repo . '/' . $test . '-' . $version);
             if ($success && is_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip')) {
                 $file_size = round(filesize(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip') / 1024, 2);
                 $info = $file_size . 'KB - ' . sha1_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip');
                 $r_size = $terminal_width - strlen($qualified_identifier) - 3 - strlen($info);
                 if ($r_size > 0) {
                     echo ' ' . str_repeat('.', $terminal_width - strlen($qualified_identifier) - 3 - strlen($info)) . ' ' . $info . PHP_EOL;
                 }
                 $total_cache_count++;
                 $total_cache_size += $file_size;
             }
         }
         echo PHP_EOL;
     }
     // Cache test suites
     foreach ($available_suites as $i => $identifier) {
         $repo = substr($identifier, 0, strpos($identifier, '/'));
         $test = substr($identifier, strlen($repo) + 1);
         $repo_index = pts_openbenchmarking::read_repository_index($repo);
         echo $i + $test_count . '/' . $total_count . ': ' . $repo_index['suites'][$test]['title'] . PHP_EOL;
         foreach ($repo_index['suites'][$test]['versions'] as $version) {
             $qualified_identifier = $repo . '/' . $test . '-' . $version;
             echo $qualified_identifier;
             $success = pts_openbenchmarking::download_test_suite($repo . '/' . $test . '-' . $version);
             if ($success && is_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip')) {
                 $file_size = round(filesize(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip') / 1024, 2);
                 $info = $file_size . 'KB - ' . sha1_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip');
                 $dot_size = $terminal_width - strlen($qualified_identifier) - 3 - strlen($info);
                 echo ' ' . str_repeat('.', $dot_size >= 0 ? $dot_size : 0) . ' ' . $info . PHP_EOL;
                 $total_cache_count++;
                 $total_cache_size += $file_size;
             }
         }
         echo PHP_EOL;
     }
     echo PHP_EOL . $total_cache_count . ' Files Cached' . PHP_EOL . $test_count . ' Test Profiles' . PHP_EOL . $suite_count . ' Test Suites' . PHP_EOL . $total_cache_size . 'KB Total Cache Size' . PHP_EOL . PHP_EOL;
 }
開發者ID:ShaolongHu,項目名稱:phoronix-test-suite,代碼行數:61,代碼來源:make_openbenchmarking_cache.php

示例4: test_install_progress_start

 public function test_install_progress_start($process)
 {
     $this->progress_line_prefix = $process;
     $this->progress_last_float = -1;
     $this->progress_tab_count = 1;
     $this->progress_string_length = pts_client::terminal_width() > 1 ? pts_client::terminal_width() - 4 : 20;
     return;
 }
開發者ID:pchiruma,項目名稱:phoronix-test-suite,代碼行數:8,代碼來源:pts_web_display_mode.php

示例5: run

 public static function run($r)
 {
     $result_file = new pts_result_file($r[0]);
     $result_output = pts_result_file_output::result_file_to_text($result_file, pts_client::terminal_width());
     echo $result_output;
 }
開發者ID:ShaolongHu,項目名稱:phoronix-test-suite,代碼行數:6,代碼來源:result_file_to_text.php


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