• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP pts_math类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了pts_math类的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: run

 public static function run($r)
 {
     define('PHOROMATIC_PROCESS', true);
     $commands = array('detailed_system_info' => null, 'list_available_tests' => null, 'list_available_suites' => null, 'info' => array('pts/all'), 'clone_openbenchmarking_result' => array('1107247-LI-MESACOMMI48', '1509040-HA-GCCINTELS17', '1508201-HA-GTX95073337', '1508233-HA-INTELSKYL16'), 'refresh_graphs' => array('1107247-LI-MESACOMMI48'), 'result_file_to_text' => array('1107247-LI-MESACOMMI48'), 'merge_results' => array('1107247-LI-MESACOMMI48', '1509040-HA-GCCINTELS17', '1508201-HA-GTX95073337', '1508233-HA-INTELSKYL16'), 'diagnostics' => null, 'dump_possible_options' => null, 'debug_render_test' => 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);
             $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 . 'TOTAL 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:pacificIT,项目名称:phoronix-test-suite,代码行数:29,代码来源:debug_self_test.php


示例3: mem_usage_bsd

 private function mem_usage_bsd($TYPE = 'TOTAL', $READ = 'USED')
 {
     $vmstats = explode("\n", shell_exec('vm_stat 2>&1'));
     // buffers_and_cache
     foreach ($vmstats as $vmstat_line) {
         $line_parts = pts_strings::colon_explode($vmstat_line);
         if (self::$page_size == -1) {
             strtok($vmstat_line, ':');
             $tok = strtok(' ');
             while (self::$page_size == -1) {
                 if (is_numeric($tok)) {
                     self::$page_size = $tok;
                 } else {
                     $tok = strtok(' ');
                 }
             }
             continue;
         }
         //$line_parts[1] = pts_strings::trim_spaces($line_parts[1]);
         $line_type = strtok($vmstat_line, ':');
         $line_value = strtok(' .');
         if ($TYPE == 'MEMORY') {
             if ($line_type == 'Pages active' && $READ == 'USED') {
                 $mem_usage = $line_value / (1048576 / self::$page_size);
                 break;
             }
             if ($line_type == 'Pages free' && $READ == 'FREE') {
                 $mem_usage = $line_value / (1048576 / self::$page_size);
                 break;
             }
         }
     }
     return pts_math::set_precision($mem_usage);
 }
开发者ID:ptzafrir,项目名称:phoronix-test-suite,代码行数:34,代码来源:memory_usage.php


示例4: read_sensor

 public static function read_sensor()
 {
     // Determine current percentage for processor usage
     if (phodevi::is_linux() || phodevi::is_bsd()) {
         $start_load = self::cpu_load_array(-1);
         sleep(1);
         $end_load = self::cpu_load_array(-1);
         for ($i = 0; $i < count($end_load); $i++) {
             $end_load[$i] -= $start_load[$i];
         }
         $percent = ($sum = array_sum($end_load)) == 0 ? 0 : 100 - $end_load[count($end_load) - 1] * 100 / $sum;
     } else {
         if (phodevi::is_solaris()) {
             // TODO: Add support for monitoring load on a per-core basis (through mpstat maybe?)
             $info = explode(' ', pts_strings::trim_spaces(pts_arrays::last_element(explode("\n", trim(shell_exec('sar -u 1 1 2>&1'))))));
             $percent = $info[1] + $info[2];
         } else {
             if (phodevi::is_macosx()) {
                 // CPU usage for user
                 $top = shell_exec('top -n 1 -l 1 2>&1');
                 $top = substr($top, strpos($top, 'CPU usage: ') + 11);
                 $percent = substr($top, 0, strpos($top, '%'));
             } else {
                 $percent = null;
             }
         }
     }
     if (!is_numeric($percent) || $percent < 0 || $percent > 100) {
         $percent = -1;
     }
     return pts_math::set_precision($percent, 2);
 }
开发者ID:rkingsbury,项目名称:phoronix-test-suite,代码行数:32,代码来源:cpu_usage.php


示例5: render_graph_bars

 protected function render_graph_bars()
 {
     $bar_count = count($this->graph_data);
     $separator_width = ($a = 8 - floor($bar_count / 2) * 2) > 0 ? $a : 0;
     $bar_width = floor(($this->i['identifier_width'] - $separator_width - $bar_count * $separator_width) / $bar_count);
     for ($i_o = 0; $i_o < $bar_count; $i_o++) {
         $paint_color = $this->get_paint_color(isset($this->graph_data_title[$i_o]) ? $this->graph_data_title[$i_o] : null);
         foreach (array_keys($this->graph_data[$i_o]) as $i) {
             $value = pts_math::set_precision($this->graph_data[$i_o][$i], 2);
             $graph_size = round($value / $this->i['graph_max_value'] * ($this->i['graph_top_end'] - $this->i['top_start']));
             $value_plot_top = max($this->i['graph_top_end'] + 1 - $graph_size, 1);
             $px_bound_left = $this->i['left_start'] + $this->i['identifier_width'] * $i + $bar_width * $i_o + $separator_width * ($i_o + 1);
             $px_bound_right = $px_bound_left + $bar_width;
             $title_tooltip = $this->graph_identifiers[$i] . ': ' . $value;
             $run_std_deviation = isset($this->graph_data_raw[$i_o][$i]) ? pts_math::standard_deviation(pts_strings::colon_explode($this->graph_data_raw[$i_o][$i])) : 0;
             if ($run_std_deviation > 0) {
                 $title_tooltip .= ' || ' . pts_math::set_precision($run_std_deviation, 1) . ' STD';
             }
             $this->svg_dom->add_element('rect', array('x' => $px_bound_left + 1, 'y' => $value_plot_top, 'width' => $bar_width, 'height' => $this->i['graph_top_end'] - $value_plot_top, 'fill' => in_array($this->graph_identifiers[$i], $this->value_highlights) ? self::$c['color']['alert'] : $paint_color, 'stroke' => self::$c['color']['body_light'], 'stroke-width' => 1, 'xlink:title' => $title_tooltip));
             if ($px_bound_right - $px_bound_left < 15) {
                 // The bars are too skinny to be able to plot anything on them
                 continue;
             }
             $x = $px_bound_left + ($px_bound_right - $px_bound_left) / 2;
             if ($graph_size > 18) {
                 $this->svg_dom->add_text_element($value, array('x' => $x, 'y' => $value_plot_top + 2, 'font-size' => floor(self::$c['size']['bars'] * 0.9), 'fill' => self::$c['color']['body_text'], 'text-anchor' => 'middle', 'dominant-baseline' => 'text-before-edge'));
             } else {
                 // Make things more compact
                 $this->svg_dom->add_text_element($value, array('x' => $x, 'y' => $value_plot_top + 2, 'font-size' => floor(self::$c['size']['bars'] * 0.6), 'fill' => self::$c['color']['body_text'], 'text-anchor' => 'middle', 'dominant-baseline' => 'text-before-edge'));
             }
         }
     }
     // write a new line along the bottom since the draw_rectangle_with_border above had written on top of it
     $this->svg_dom->draw_svg_line($this->i['left_start'], $this->i['graph_top_end'], $this->i['graph_left_end'], $this->i['graph_top_end'], self::$c['color']['notches'], 1);
 }
开发者ID:rkingsbury,项目名称:phoronix-test-suite,代码行数:35,代码来源:pts_VerticalBarGraph.php


示例6: cpu_temp_linux

 private function cpu_temp_linux()
 {
     $temp_c = -1;
     // Try hwmon interface
     $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/temp2_input', 'POSITIVE_NUMERIC', array('name' => 'coretemp'));
     if ($raw_temp == -1) {
         $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp1_input', 'POSITIVE_NUMERIC', array('name' => 'k10temp'));
     }
     if ($raw_temp == -1) {
         // Try ACPI thermal
         // Assuming the system thermal sensor comes 2nd to the ACPI CPU temperature
         // It appears that way on a ThinkPad T60, but TODO find a better way to validate
         $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/thermal/thermal_zone*/temp', 'POSITIVE_NUMERIC', null, 2);
     }
     if ($raw_temp != -1) {
         if ($raw_temp > 1000) {
             $raw_temp = $raw_temp / 1000;
         }
         $temp_c = pts_math::set_precision($raw_temp, 2);
     }
     if ($temp_c == -1) {
         // Try LM_Sensors
         $sensors = phodevi_linux_parser::read_sensors(array('CPU Temp', 'Core 0', 'Core0 Temp', 'Core1 Temp'));
         if ($sensors != false && is_numeric($sensors) && $sensors > 0) {
             $temp_c = $sensors;
         }
     }
     if (pts_client::executable_in_path('ipmitool')) {
         $ipmi = phodevi_linux_parser::read_ipmitool_sensor('Temp 0');
         if ($ipmi > 0 && is_numeric($ipmi)) {
             $temp_c = $ipmi;
         }
     }
     return $temp_c;
 }
开发者ID:ptzafrir,项目名称:phoronix-test-suite,代码行数:35,代码来源:cpu_temp.php


示例7: read_sensor

 public function read_sensor()
 {
     $net_speed = -1;
     if (phodevi::is_bsd() || phodevi::is_macosx()) {
         $net_speed = $this->network_usage_bsd();
     }
     return pts_math::set_precision($net_speed, 2);
 }
开发者ID:numerant,项目名称:phoronix-test-suite,代码行数:8,代码来源:network_usage.php


示例8: read_sensor

 public function read_sensor()
 {
     $temp = -1;
     if (phodevi::is_linux()) {
         $temp = $this->hdd_temp_linux();
     }
     return pts_math::set_precision($temp, 2);
 }
开发者ID:numerant,项目名称:phoronix-test-suite,代码行数:8,代码来源:hdd_temp.php


示例9: read_sensor

 public function read_sensor()
 {
     $write_speed = -1;
     if (phodevi::is_linux()) {
         $write_speed = $this->hdd_write_speed_linux();
     }
     return pts_math::set_precision($write_speed, 2);
 }
开发者ID:ShaolongHu,项目名称:phoronix-test-suite,代码行数:8,代码来源:hdd_write_speed.php


示例10: bytes_to_download_size

 protected function bytes_to_download_size($bytes)
 {
     $mb = pts_math::set_precision($bytes / 1048576, 2);
     if ($mb > 99) {
         $mb = ceil($mb);
     }
     return $mb;
 }
开发者ID:rkingsbury,项目名称:phoronix-test-suite,代码行数:8,代码来源:pts_websocket_display_mode.php


示例11: read_sensor

 public static function read_sensor()
 {
     // Read the processor temperature
     $temp_c = -1;
     if (phodevi::is_bsd()) {
         $cpu_temp = phodevi_bsd_parser::read_sysctl(array('hw.sensors.acpi_tz0.temp0', 'dev.cpu.0.temperature', 'hw.sensors.cpu0.temp0'));
         if ($cpu_temp != false) {
             if (($end = strpos($cpu_temp, 'degC')) || ($end = strpos($cpu_temp, 'C')) > 0) {
                 $cpu_temp = substr($cpu_temp, 0, $end);
             }
             if (is_numeric($cpu_temp)) {
                 $temp_c = $cpu_temp;
             }
         } else {
             $acpi = phodevi_bsd_parser::read_sysctl('hw.acpi.thermal.tz0.temperature');
             if (($end = strpos($acpi, 'C')) > 0) {
                 $acpi = substr($acpi, 0, $end);
             }
             if (is_numeric($acpi)) {
                 $temp_c = $acpi;
             }
         }
     } else {
         if (phodevi::is_linux()) {
             // Try hwmon interface
             $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp1_input', 'POSITIVE_NUMERIC', array('name' => 'coretemp'));
             if ($raw_temp == -1) {
                 $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp1_input', 'POSITIVE_NUMERIC', array('name' => 'k10temp'));
             }
             if ($raw_temp == -1) {
                 // Try ACPI thermal
                 // Assuming the system thermal sensor comes 2nd to the ACPI CPU temperature
                 // It appears that way on a ThinkPad T60, but TODO find a better way to validate
                 $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/thermal/thermal_zone*/temp', 'POSITIVE_NUMERIC', null, 2);
             }
             if ($raw_temp != -1) {
                 if ($raw_temp > 1000) {
                     $raw_temp = $raw_temp / 1000;
                 }
                 $temp_c = pts_math::set_precision($raw_temp, 2);
             }
             if ($temp_c == -1) {
                 // Try LM_Sensors
                 $sensors = phodevi_linux_parser::read_sensors(array('CPU Temp', 'Core 0', 'Core0 Temp', 'Core1 Temp'));
                 if ($sensors != false && is_numeric($sensors) && $sensors > 0) {
                     $temp_c = $sensors;
                 }
             }
             if (pts_client::executable_in_path('ipmitool')) {
                 $ipmi = phodevi_linux_parser::read_ipmitool_sensor('Temp 0');
                 if ($ipmi > 0 && is_numeric($ipmi)) {
                     $temp_c = $ipmi;
                 }
             }
         }
     }
     return $temp_c;
 }
开发者ID:rkingsbury,项目名称:phoronix-test-suite,代码行数:58,代码来源:cpu_temp.php


示例12: percent_standard_deviation

 public static function percent_standard_deviation($values)
 {
     if (count($values) == 0) {
         // No values
         return 0;
     }
     $standard_deviation = pts_math::standard_deviation($values);
     $average_value = array_sum($values) / count($values);
     return $average_value != 0 ? $standard_deviation / $average_value * 100 : 0;
 }
开发者ID:ShaolongHu,项目名称:phoronix-test-suite,代码行数:10,代码来源:pts_math.php


示例13: increase_run_count_check

 public function increase_run_count_check(&$test_results, $scheduled_times_to_run, $latest_test_run_time)
 {
     // First make sure this test doesn't take too long to run where we don't want dynamic handling
     if (floor($latest_test_run_time / 60) > $this->dynamic_run_count_on_length_or_less) {
         return false;
     }
     // Determine if results are statistically significant, otherwise up the run count
     $std_dev = pts_math::percent_standard_deviation($test_results->test_result_buffer->get_values());
     if ($std_dev >= $this->dynamic_run_count_std_deviation_threshold) {
         static $last_run_count = 128;
         // just a number that should always cause the first check below to be true
         static $run_std_devs;
         $times_already_ran = $test_results->test_result_buffer->get_count();
         if ($times_already_ran <= $last_run_count) {
             // We're now onto a new test so clear out the array
             $run_std_devs = array();
         }
         $last_run_count = $times_already_ran;
         $run_std_devs[$last_run_count] = $std_dev;
         // If we haven't reached scheduled times to run x 2, increase count straight away
         if ($times_already_ran < $scheduled_times_to_run * 2) {
             return true;
         } else {
             if ($times_already_ran < $scheduled_times_to_run * 3) {
                 // More aggressive determination whether to still keep increasing the run count
                 $first_and_now_diff = pts_arrays::first_element($run_std_devs) - pts_arrays::last_element($run_std_devs);
                 // Increasing the run count at least looks to be helping...
                 if ($first_and_now_diff > pts_arrays::first_element($run_std_devs) / 2) {
                     // If we are at least making progress in the right direction, increase the run count some more
                     return true;
                 }
                 // TODO: could add more checks and take better advantage of the array of data to better determine if it's still worth increasing
             }
         }
     }
     // Check to see if there is an external/custom script to export the results to in determining whether results are valid
     if (($ex_file = $this->dynamic_run_count_export_script) != null && is_executable($ex_file) || is_executable($ex_file = PTS_USER_PATH . $this->dynamic_run_count_export_script)) {
         $exit_status = trim(shell_exec($ex_file . ' ' . $test_results->test_result_buffer->get_values_as_string() . ' > /dev/null 2>&1; echo $?'));
         switch ($exit_status) {
             case 1:
                 // Run the test again
                 return true;
             case 2:
                 // Results are bad, abandon testing and do not record results
                 return -1;
             case 0:
             default:
                 // Return was 0 or something else, results are valid, or was some other exit status
                 break;
         }
     }
     // No reason to increase the run count with none of the previous checks requesting otherwise
     return false;
 }
开发者ID:pchiruma,项目名称:phoronix-test-suite,代码行数:54,代码来源:pts_test_run_manager.php


示例14: get_change_formatted

 public function get_change_formatted()
 {
     $direction = '-';
     if ($this->test_proportion == 'HIB' && $this->get_regressed_value() > $this->get_base_value()) {
         $direction = '+';
     } else {
         if ($this->test_proportion == 'LIB' && $this->get_regressed_value() < $this->get_base_value()) {
             $direction = '+';
         }
     }
     return $direction . pts_math::set_precision($this->get_change() * 100, 2);
 }
开发者ID:ShaolongHu,项目名称:phoronix-test-suite,代码行数:12,代码来源:pts_test_result_regression_marker.php


示例15: read_sensor

 public static function read_sensor()
 {
     // Reads the system's temperature
     $temp_c = -1;
     if (phodevi::is_linux()) {
         $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp3_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
         if ($raw_temp == -1) {
             $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp2_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
         }
         if ($raw_temp == -1) {
             $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp1_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
         }
         if ($raw_temp == -1) {
             $raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/temp1_input', 'POSITIVE_NUMERIC');
         }
         if ($raw_temp != -1) {
             if ($raw_temp > 1000) {
                 $raw_temp = $raw_temp / 1000;
             }
             $temp_c = pts_math::set_precision($raw_temp, 2);
         }
         if ($temp_c == -1) {
             $acpi = phodevi_linux_parser::read_acpi(array('/thermal_zone/THM1/temperature', '/thermal_zone/TZ00/temperature', '/thermal_zone/TZ01/temperature'), 'temperature');
             if (($end = strpos($acpi, ' ')) > 0) {
                 $temp_c = substr($acpi, 0, $end);
             }
         }
         if ($temp_c == -1) {
             $sensors = phodevi_linux_parser::read_sensors(array('Sys Temp', 'Board Temp'));
             if ($sensors != false && is_numeric($sensors)) {
                 $temp_c = $sensors;
             }
         }
         if ($temp_c == -1 && is_file('/sys/class/thermal/thermal_zone0/temp')) {
             $temp_c = pts_file_io::file_get_contents('/sys/class/thermal/thermal_zone0/temp');
             if ($temp_c > 1000) {
                 $temp_c = pts_math::set_precision($temp_c / 1000, 1);
             }
         }
     } else {
         if (phodevi::is_bsd()) {
             $acpi = phodevi_bsd_parser::read_sysctl(array('hw.sensors.acpi_tz1.temp0', 'hw.acpi.thermal.tz1.temperature'));
             if (($end = strpos($acpi, ' degC')) > 0 || ($end = strpos($acpi, 'C')) > 0) {
                 $acpi = substr($acpi, 0, $end);
                 if (is_numeric($acpi)) {
                     $temp_c = $acpi;
                 }
             }
         }
     }
     return $temp_c;
 }
开发者ID:rkingsbury,项目名称:phoronix-test-suite,代码行数:52,代码来源:sys_temp.php


示例16: swap_usage_linux

 private function swap_usage_linux()
 {
     $proc_meminfo = explode("\n", file_get_contents('/proc/meminfo'));
     $mem = array();
     foreach ($proc_meminfo as $mem_line) {
         $line_split = preg_split('/\\s+/', $mem_line);
         if (count($line_split) == 3) {
             $mem[$line_split[0]] = intval($line_split[1]);
         }
     }
     $used_mem = $mem['SwapTotal:'] - $mem['SwapFree:'];
     return pts_math::set_precision($used_mem / 1024, 0);
 }
开发者ID:numerant,项目名称:phoronix-test-suite,代码行数:13,代码来源:swap_usage.php


示例17: cpu_power_linux

 private function cpu_power_linux()
 {
     $cpu_watts = -1;
     // Try hwmon interface for AMD 15h (Bulldozer FX CPUs) where this support was introduced for AMD CPUs and exposed by the fam15h_power hwmon driver
     // The fam15h_power driver doesn't expose the power consumption on a per-core/per-package basis but only an average
     $hwmon_watts = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/power1_input', 'POSITIVE_NUMERIC', array('name' => 'fam15h_power'));
     if ($hwmon_watts != -1) {
         if ($hwmon_watts > 1000000) {
             // convert to Watts
             $hwmon_watts = $hwmon_watts / 1000000;
         }
         $cpu_watts = pts_math::set_precision($hwmon_watts, 2);
     }
     return $cpu_watts;
 }
开发者ID:ShaolongHu,项目名称:phoronix-test-suite,代码行数:15,代码来源:cpu_power.php


示例18: read_sensor

 public function read_sensor()
 {
     $start_sys_jiffies = self::cpu_jiffies_count();
     $start_cgroup_jiffies = self::cgroup_cpu_jiffies_count();
     usleep(500000);
     $end_sys_jiffies = self::cpu_jiffies_count();
     $end_cgroup_jiffies = self::cgroup_cpu_jiffies_count();
     $diff_sys_jiffies = $end_sys_jiffies - $start_sys_jiffies;
     $diff_cgroup_jiffies = $end_cgroup_jiffies - $start_cgroup_jiffies;
     $percent = $diff_sys_jiffies == 0 ? 0 : $diff_cgroup_jiffies / $diff_sys_jiffies * 100;
     if (!is_numeric($percent) || $percent < 0 || $percent > 100) {
         $percent = -1;
     }
     return pts_math::set_precision($percent, 2);
 }
开发者ID:ShaolongHu,项目名称:phoronix-test-suite,代码行数:15,代码来源:cgroup_cpu_usage.php


示例19: read_sensor

 public static function read_sensor()
 {
     $iowait = -1;
     if (phodevi::is_linux() && is_file('/proc/stat')) {
         $start_stat = pts_file_io::file_get_contents('/proc/stat');
         sleep(1);
         $end_stat = pts_file_io::file_get_contents('/proc/stat');
         $start_stat = explode(' ', substr($start_stat, 0, strpos($start_stat, "\n")));
         $end_stat = explode(' ', substr($end_stat, 0, strpos($end_stat, "\n")));
         for ($i = 2, $diff_cpu_total = 0; $i < 9; $i++) {
             $diff_cpu_total += $end_stat[$i] - $start_stat[$i];
         }
         $diff_iowait = $end_stat[6] - $start_stat[6];
         $iowait = pts_math::set_precision(1000 * $diff_iowait / $diff_cpu_total / 10, 2);
     }
     return $iowait;
 }
开发者ID:rkingsbury,项目名称:phoronix-test-suite,代码行数:17,代码来源:sys_iowait.php


示例20: render_graph_finish

 public function render_graph_finish()
 {
     $this->render_graph_identifiers();
     $this->render_graph_heading(false);
     $pie_slices = count($this->graph_identifiers);
     $radius = min($this->i['graph_height'] - $this->i['top_start'] - $this->i['top_end_bottom'], $this->i['graph_width'] - $this->i['left_start'] - $this->i['left_end_right']) / 2;
     $center_x = $this->i['graph_width'] / 2;
     $center_y = $this->i['top_start'] + ($this->i['graph_height'] - $this->i['top_start'] - $this->i['top_end_bottom']) / 2;
     $offset_percent = 0;
     for ($i = 0; $i < $pie_slices; $i++) {
         $percent = pts_math::set_precision($this->graph_data[0][$i] / $this->i['pie_sum'], 3);
         $this->svg_dom->draw_svg_arc($center_x, $center_y, $radius, $offset_percent, $percent, array('fill' => $this->get_paint_color($i), 'stroke' => self::$c['color']['border'], 'stroke-width' => 2, 'xlink:title' => $this->graph_identifiers[$i] . ': ' . $this->graph_data[0][$i]));
         $offset_percent += $percent;
     }
     if (!empty(self::$c['text']['watermark'])) {
         $this->svg_dom->add_text_element(self::$c['text']['watermark'], array('x' => $this->i['graph_width'] / 2, 'y' => $this->i['graph_height'] - 15, 'font-size' => 10, 'fill' => self::$c['color']['text'], 'text-anchor' => 'middle', 'dominant-baseline' => 'text-before-edge'));
     }
 }
开发者ID:rkingsbury,项目名称:phoronix-test-suite,代码行数:18,代码来源:pts_PieChart.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP pts_openbenchmarking类代码示例发布时间:2022-05-23
下一篇:
PHP pts_file_io类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap