本文整理汇总了PHP中pts_strings::colon_explode方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_strings::colon_explode方法的具体用法?PHP pts_strings::colon_explode怎么用?PHP pts_strings::colon_explode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_strings
的用法示例。
在下文中一共展示了pts_strings::colon_explode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read_osx_system_profiler
public static function read_osx_system_profiler($data_type, $object, $multiple_objects = false, $ignore_values = array())
{
$value = $multiple_objects ? array() : false;
if (pts_client::executable_in_path('system_profiler')) {
$info = trim(shell_exec('system_profiler ' . $data_type . ' 2>&1'));
$lines = explode("\n", $info);
for ($i = 0; $i < count($lines) && ($value == false || $multiple_objects); $i++) {
$line = pts_strings::colon_explode($lines[$i]);
if (isset($line[0]) == false) {
continue;
}
$line_object = str_replace(' ', null, $line[0]);
if (($cut_point = strpos($line_object, '(')) > 0) {
$line_object = substr($line_object, 0, $cut_point);
}
if (strtolower($line_object) == strtolower($object) && isset($line[1])) {
$this_value = trim($line[1]);
if (!empty($this_value) && !in_array($this_value, $ignore_values)) {
if ($multiple_objects) {
array_push($value, $this_value);
} else {
$value = $this_value;
}
}
}
}
}
return $value;
}
示例2: 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);
}
示例3: 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);
}
示例4: render_graph_candle_sticks
protected function render_graph_candle_sticks()
{
$bar_count = count($this->graph_data_raw);
$bar_width = floor($this->i['identifier_width'] / $bar_count) - $bar_count * 16;
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);
for ($i = 0; $i < count($this->graph_data_raw[$i_o]); $i++) {
$run_values_r = pts_strings::colon_explode($this->graph_data_raw[$i_o][$i]);
$start_value = $run_values_r[0];
$end_value = $run_values_r[count($run_values_r) - 1];
$average_value = array_sum($run_values_r) / count($run_values_r);
sort($run_values_r);
$low_value = $run_values_r[0];
$high_value = $run_values_r[count($run_values_r) - 1];
$px_bound_left = $this->i['left_start'] + $this->i['identifier_width'] * $i + $bar_width * $i_o + 8;
$px_bound_center = $px_bound_left + round($bar_width / 2);
$top_diff = $this->i['graph_top_end'] - $this->i['top_start'];
$plot_wick_lowest = $this->i['graph_top_end'] + 1 - round($low_value / $this->i['graph_max_value'] * $top_diff);
$plot_wick_highest = $this->i['graph_top_end'] + 1 - round($high_value / $this->i['graph_max_value'] * $top_diff);
$plot_body_start = $this->i['graph_top_end'] + 1 - round($start_value / $this->i['graph_max_value'] * $top_diff);
$plot_body_end = $this->i['graph_top_end'] + 1 - round($end_value / $this->i['graph_max_value'] * $top_diff);
if ($start_value > $end_value) {
$body_color = self::$c['color']['body'];
$plot_body_high = $plot_body_start;
$plot_body_low = $plot_body_end;
} else {
$body_color = $paint_color;
$plot_body_low = $plot_body_start;
$plot_body_high = $plot_body_end;
}
$this->svg_dom->draw_svg_line($px_bound_center, $plot_wick_lowest, $px_bound_center, $plot_wick_highest, self::$c['color']['body_light'], 1);
$this->svg_dom->add_element('rect', array('x' => $px_bound_left, 'y' => $plot_body_low, 'width' => $bar_width, 'height' => $plot_body_high - $plot_body_low, 'fill' => $body_color, 'stroke' => self::$c['color']['body_light'], 'stroke-width' => 1));
}
}
}
示例5: add_test_result
public function add_test_result($mto)
{
$total_objects = count($this->test_results);
$this->test_results[$total_objects] = $mto;
$attributes = array_reverse(explode(' - ', $mto->get_arguments_description()));
$attributes_clean = array();
for ($i = 0; $i < count($attributes); $i++) {
$temp = pts_strings::colon_explode($attributes[$i]);
$attributes_clean[$temp[0]] = isset($temp[1]) ? $temp[1] : null;
}
if (!isset($this->relations[$mto->test_profile->get_identifier()][$mto->test_profile->get_test_profile_version()])) {
$this->relations[$mto->test_profile->get_identifier()][$mto->test_profile->get_test_profile_version()] = array();
}
array_push($this->relations[$mto->test_profile->get_identifier()][$mto->test_profile->get_test_profile_version()], array($total_objects, $attributes_clean));
}
示例6: read_sun_ddu_dmi_info
public static function read_sun_ddu_dmi_info($find_objects, $args = null)
{
// Read Sun's Device Driver Utility for OpenSolaris
$values = array();
if (in_array(phodevi::read_property('system', 'kernel-architecture'), array('i686', 'x86_64'))) {
$dmi_info = '/usr/ddu/bin/i386/dmi_info';
} else {
$dmi_info = '/usr/ddu/bin/sparc/dmi_info';
}
if (is_executable($dmi_info) || is_executable($dmi_info = '/usr/ddu/bin/dmi_info')) {
$info = shell_exec($dmi_info . ' ' . $args . ' 2>&1');
$lines = explode("\n", $info);
$find_objects = pts_arrays::to_array($find_objects);
for ($i = 0; $i < count($find_objects) && count($values) == 0; $i++) {
$objects = pts_strings::comma_explode($find_objects[$i]);
$this_section = null;
if (count($objects) == 2) {
$section = $objects[0];
$object = $objects[1];
} else {
$section = null;
$object = $objects[0];
}
foreach ($lines as $line) {
$line = pts_strings::colon_explode($line);
$line_object = isset($line[0]) ? str_replace(' ', null, $line[0]) : null;
$this_value = count($line) > 1 ? $line[1] : null;
if (empty($this_value) && !empty($section)) {
$this_section = $line_object;
}
if ($line_object == $object && ($this_section == $section || pts_strings::proximity_match($section, $this_section)) && !empty($this_value) && $this_value != 'Unknown') {
array_push($values, $this_value);
}
}
}
}
return $values;
}
示例7: sw_desktop_environment
public static function sw_desktop_environment()
{
$desktop = null;
$desktop_environment = null;
$desktop_version = null;
$desktop_session = pts_client::read_env('DESKTOP_SESSION');
if (pts_client::is_process_running('gnome-shell')) {
// GNOME 3.0 / GNOME Shell
$desktop_environment = 'GNOME Shell';
if (pts_client::executable_in_path('gnome-shell')) {
$desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-shell --version 2> /dev/null')));
}
} else {
if (pts_client::is_process_running('gnome-panel') || $desktop_session == 'gnome') {
// GNOME
$desktop_environment = 'GNOME';
if (pts_client::executable_in_path('gnome-about')) {
$desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-about --version 2> /dev/null')));
} else {
if (pts_client::executable_in_path('gnome-session')) {
$desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-session --version 2> /dev/null')));
}
}
} else {
if (pts_client::is_process_running('unity-2d-panel') || $desktop_session == 'ubuntu-2d') {
// Canonical / Ubuntu Unity 2D Desktop
$desktop_environment = 'Unity 2D';
if (pts_client::executable_in_path('unity')) {
$desktop_version = pts_strings::last_in_string(trim(shell_exec('unity --version 2> /dev/null')));
}
} else {
if (pts_client::is_process_running('unity-panel-service') || $desktop_session == 'ubuntu') {
// Canonical / Ubuntu Unity Desktop
$desktop_environment = 'Unity';
if (pts_client::executable_in_path('unity')) {
$desktop_version = pts_strings::last_in_string(trim(shell_exec('unity --version 2> /dev/null')));
}
} else {
if ($desktop_session == 'mate') {
$desktop_environment = 'MATE';
if (pts_client::executable_in_path('mate-about')) {
$desktop_version = pts_strings::last_in_string(trim(shell_exec('mate-about --version 2> /dev/null')));
}
} else {
if ($kde5 = pts_client::is_process_running('kded5')) {
// KDE 5.x
$desktop_environment = 'KDE Frameworks 5';
$desktop_version = null;
// TODO XXX
} else {
if ($dde = pts_client::is_process_running('dde-desktop')) {
// KDE 5.x
$desktop_environment = 'Deepin Desktop Environment';
$desktop_version = null;
// TODO XXX
} else {
if (($kde4 = pts_client::is_process_running('kded4')) || pts_client::is_process_running('kded')) {
// KDE 4.x
$desktop_environment = 'KDE';
$kde_output = trim(shell_exec(($kde4 ? 'kde4-config' : 'kde-config') . ' --version 2>&1'));
$kde_lines = explode("\n", $kde_output);
for ($i = 0; $i < count($kde_lines) && empty($desktop_version); $i++) {
$line_segments = pts_strings::colon_explode($kde_lines[$i]);
if (in_array($line_segments[0], array('KDE', 'KDE Development Platform')) && isset($line_segments[1])) {
$v = trim($line_segments[1]);
if (($cut = strpos($v, ' ')) > 0) {
$v = substr($v, 0, $cut);
}
$desktop_version = $v;
}
}
} else {
if (pts_client::is_process_running('chromeos-wm')) {
$chrome_output = trim(shell_exec('chromeos-wm -version'));
if ($chrome_output == 'chromeos-wm') {
// No version actually reported
$chrome_output = 'Chrome OS';
}
$desktop_environment = $chrome_output;
} else {
if (pts_client::is_process_running('lxsession') || $desktop_session == 'lxde') {
$lx_output = trim(shell_exec('lxpanel --version'));
$version = substr($lx_output, strpos($lx_output, ' ') + 1);
$desktop_environment = 'LXDE';
$desktop_version = $version;
} else {
if (pts_client::is_process_running('xfce4-session') || pts_client::is_process_running('xfce-mcs-manager') || $desktop_session == 'xfce') {
// Xfce 4.x
$desktop_environment = 'Xfce';
$xfce_output = trim(shell_exec('xfce4-session-settings --version 2>&1'));
if (($open = strpos($xfce_output, '(Xfce')) > 0) {
$xfce_output = substr($xfce_output, strpos($xfce_output, ' ', $open) + 1);
$desktop_version = substr($xfce_output, 0, strpos($xfce_output, ')'));
}
} else {
if (pts_client::is_process_running('sugar-session')) {
// Sugar Desktop Environment (namely for OLPC)
$desktop_environment = 'Sugar';
$desktop_version = null;
// TODO: where can the Sugar version be figured out?
//.........这里部分代码省略.........
示例8: render_graph_bars
protected function render_graph_bars()
{
$bar_count = count($this->results);
$separator_height = ($a = 6 - floor($bar_count / 2) * 2) > 0 ? $a : 0;
$bar_height = floor(($this->i['identifier_height'] - ($this->is_multi_way_comparison ? 4 : 0) - $separator_height - $bar_count * $separator_height) / $bar_count);
$this->i['graph_max_value'] = $this->i['graph_max_value'] != 0 ? $this->i['graph_max_value'] : 1;
$work_area_width = $this->i['graph_left_end'] - $this->i['left_start'];
$group_offsets = array();
$id_offsets = array();
$g_bars = $this->svg_dom->make_g(array('stroke' => self::$c['color']['body_light'], 'stroke-width' => 1));
$g_se = $this->svg_dom->make_g(array('font-size' => $this->i['identifier_size'] - 2, 'fill' => self::$c['color']['text'], 'text-anchor' => 'end'));
$g_values = $this->svg_dom->make_g(array('font-size' => $this->i['identifier_size'], 'fill' => self::$c['color']['body_text']));
$bar_x = $this->i['left_start'] + 0.5;
foreach ($this->results as $identifier => &$group) {
$paint_color = $this->get_paint_color($identifier);
foreach ($group as &$buffer_item) {
// if identifier is 0, not a multi-way comparison or anything special
if ($identifier == 0 && !$this->is_multi_way_comparison) {
// See if the result identifier matches something to be color-coded better
$result_identifier = strtolower($buffer_item->get_result_identifier());
if (strpos($result_identifier, 'geforce') !== false || strpos($result_identifier, 'nvidia') !== false) {
$paint_color = '#77b900';
} else {
if (strpos($result_identifier, 'radeon') !== false || strpos($result_identifier, 'amd ') !== false) {
$paint_color = '#f1052d';
} else {
if (strpos($result_identifier, 'intel ') !== false) {
$paint_color = '#0b5997';
}
}
}
}
$i_o = $this->calc_offset($group_offsets, $identifier);
$i = $this->calc_offset($id_offsets, $buffer_item->get_result_identifier());
$value = $buffer_item->get_result_value();
$graph_size = max(0, round($value / $this->i['graph_max_value'] * $work_area_width));
$value_end_right = max($this->i['left_start'] + $graph_size, 1);
$px_bound_top = $this->i['top_start'] + ($this->is_multi_way_comparison ? 5 : 0) + $this->i['identifier_height'] * $i + $bar_height * $i_o + $separator_height * ($i_o + 1);
$px_bound_bottom = $px_bound_top + $bar_height;
$middle_of_bar = $px_bound_top + $bar_height / 2 + ($this->i['identifier_size'] - 4);
$title_tooltip = $buffer_item->get_result_identifier() . ': ' . $value;
$std_error = -1;
if ($raw_values = $buffer_item->get_result_raw()) {
$std_error = pts_strings::colon_explode($raw_values);
switch (count($std_error)) {
case 0:
$std_error = -1;
break;
case 1:
$std_error = 0;
break;
default:
$std_error = pts_math::standard_error($std_error);
break;
}
}
$this->svg_dom->add_element('rect', array('x' => $bar_x, 'y' => $px_bound_top + 0.5, 'height' => $bar_height, 'width' => $graph_size, 'fill' => in_array($buffer_item->get_result_identifier(), $this->value_highlights) ? self::$c['color']['highlight'] : $paint_color, 'xlink:title' => $title_tooltip), $g_bars);
if ($std_error != -1 && $value != null) {
$std_error_height = 8;
if ($std_error > 0 && is_numeric($std_error)) {
$std_error_rel_size = round($std_error / $this->i['graph_max_value'] * ($this->i['graph_left_end'] - $this->i['left_start']));
if ($std_error_rel_size > 4) {
$std_error_base_left = $value_end_right - $std_error_rel_size + 0.5;
$std_error_base_right = $value_end_right + $std_error_rel_size + 0.5;
$this->svg_dom->draw_svg_line($std_error_base_left, $px_bound_top, $std_error_base_left, $px_bound_top + $std_error_height, self::$c['color']['notches'], 1);
$this->svg_dom->draw_svg_line($std_error_base_right, $px_bound_top, $std_error_base_right, $px_bound_top + $std_error_height, self::$c['color']['notches'], 1);
$this->svg_dom->draw_svg_line($std_error_base_left, $px_bound_top + 0.5, $std_error_base_right, $px_bound_top + 0.5, self::$c['color']['notches'], 1);
}
}
$bar_offset_34 = round($middle_of_bar + ($this->is_multi_way_comparison ? 0 : $bar_height / 5 + 1));
$this->svg_dom->add_text_element('SE +/- ' . pts_math::set_precision($std_error, 2), array('y' => $bar_offset_34, 'x' => $this->i['left_start'] - 5), $g_se);
}
if (self::text_string_width($value, $this->i['identifier_size']) + 2 < $graph_size) {
if (isset($this->d['identifier_notes'][$buffer_item->get_result_identifier()]) && $this->i['compact_result_view'] == false && !$this->is_multi_way_comparison) {
$note_size = self::$c['size']['key'] - 2;
$this->svg_dom->add_text_element($this->d['identifier_notes'][$buffer_item->get_result_identifier()], array('x' => $this->i['left_start'] + 4, 'y' => $px_bound_top + self::$c['size']['key'], 'font-size' => $note_size, 'fill' => self::$c['color']['body_text'], 'text-anchor' => 'start'));
}
$this->svg_dom->add_text_element($value, array('x' => $value_end_right - 5, 'y' => $middle_of_bar, 'text-anchor' => 'end'), $g_values);
} else {
if ($value > 0) {
// Write it in front of the result
$this->svg_dom->add_text_element($value, array('x' => $value_end_right + 6, 'y' => $middle_of_bar, 'fill' => self::$c['color']['text'], 'text-anchor' => 'start'), $g_values);
}
}
}
}
}
示例9: download_cache_locations
public static function download_cache_locations()
{
static $cache_directories = null;
if ($cache_directories == null) {
$cache_directories = array();
// Phoronix Test Suite System Cache Directories
$additional_dir_checks = array('/var/cache/phoronix-test-suite/download-cache/', '/var/cache/phoronix-test-suite/');
foreach ($additional_dir_checks as $dir_check) {
if (is_dir($dir_check)) {
$cache_directories[] = $dir_check;
break;
}
}
// User Defined Directory Checking
$dir_string = ($dir = pts_client::read_env('PTS_DOWNLOAD_CACHE')) != false ? $dir : null;
foreach (array_merge(self::$extra_caches, pts_strings::colon_explode($dir_string)) as $dir_check) {
if ($dir_check == null) {
continue;
}
$dir_check = pts_strings::parse_for_home_directory($dir_check);
if (pts_strings::is_url($dir_check) == false && !is_dir($dir_check)) {
continue;
}
$cache_directories[] = pts_strings::add_trailing_slash($dir_check);
}
if (pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/SearchMediaForCache', 'TRUE')) {
$download_cache_dirs = array_merge(pts_file_io::glob('/media/*/download-cache/'), pts_file_io::glob('/media/*/*/download-cache/'), pts_file_io::glob('/run/media/*/*/download-cache/'), pts_file_io::glob('/Volumes/*/download-cache/'));
foreach ($download_cache_dirs as $dir) {
$cache_directories[] = $dir;
}
}
}
return $cache_directories;
}
示例10: client_startup
public static function client_startup()
{
if (($proxy_address = pts_config::read_user_config('PhoronixTestSuite/Options/Networking/ProxyAddress', false)) && ($proxy_port = pts_config::read_user_config('PhoronixTestSuite/Options/Networking/ProxyPort', false))) {
self::$network_proxy['proxy'] = $proxy_address . ':' . $proxy_port;
self::$network_proxy['address'] = $proxy_address;
self::$network_proxy['port'] = $proxy_port;
} else {
if (($env_proxy = getenv('http_proxy')) != false && count($env_proxy = pts_strings::colon_explode($env_proxy)) == 2) {
self::$network_proxy['proxy'] = $env_proxy[0] . ':' . $env_proxy[1];
self::$network_proxy['address'] = $env_proxy[0];
self::$network_proxy['port'] = $env_proxy[1];
}
}
self::$network_timeout = pts_config::read_user_config('PhoronixTestSuite/Options/Networking/Timeout', 20);
if (ini_get('allow_url_fopen') == 'Off') {
if (!defined('PHOROMATIC_SERVER')) {
echo PHP_EOL . 'The allow_url_fopen option in your PHP configuration must be enabled for network support.' . PHP_EOL . PHP_EOL;
}
self::$disable_network_support = true;
} else {
if (pts_config::read_bool_config('PhoronixTestSuite/Options/Networking/NoInternetCommunication', 'FALSE')) {
if (!defined('PHOROMATIC_SERVER')) {
echo PHP_EOL . 'Internet Communication Is Disabled Per Your User Configuration.' . PHP_EOL . PHP_EOL;
}
self::$disable_internet_support = true;
} else {
if (pts_config::read_bool_config('PhoronixTestSuite/Options/Networking/NoNetworkCommunication', 'FALSE')) {
if (!defined('PHOROMATIC_SERVER')) {
echo PHP_EOL . 'Network Communication Is Disabled Per Your User Configuration.' . PHP_EOL . PHP_EOL;
}
self::$disable_network_support = true;
} else {
if (pts_flags::no_network_communication() == true) {
//echo PHP_EOL . 'Network Communication Is Disabled Per Your User Configuration.' . PHP_EOL . PHP_EOL;
self::$disable_network_support = true;
} else {
if (!PTS_IS_WEB_CLIENT) {
$server_response = pts_network::http_get_contents('http://www.phoronix-test-suite.com/PTS', false, false);
if ($server_response != 'PTS') {
// Failed to connect to PTS server
// As a last resort, see if it can resolve IP to Google.com as a test for Internet connectivity...
// i.e. in case Phoronix server is down or some other issue, so just see if Google will resolve
// If google.com fails to resolve, it will simply return the original string
if (gethostbyname('google.com') == 'google.com') {
echo PHP_EOL;
if (PTS_IS_DAEMONIZED_SERVER_PROCESS) {
// Wait some seconds in case network is still coming up
foreach (array(20, 40) as $time_to_wait) {
sleep($time_to_wait);
$server_response = pts_network::http_get_contents('http://www.phoronix-test-suite.com/PTS', false, false);
if ($server_response != 'PTS' && gethostbyname('google.com') == 'google.com') {
trigger_error('No Internet Connectivity After Wait', E_USER_WARNING);
self::$disable_internet_support = true;
} else {
self::$disable_internet_support = false;
break;
}
}
} else {
trigger_error('No Internet Connectivity', E_USER_WARNING);
self::$disable_internet_support = true;
}
}
}
}
}
}
}
}
if (pts_network::network_support_available() == false && ini_get('file_uploads') == 'Off') {
echo PHP_EOL . 'The file_uploads option in your PHP configuration must be enabled for network support.' . PHP_EOL . PHP_EOL;
}
}
示例11: render_graph_start
public function render_graph_start()
{
// Needs to be at least 86px wide for the PTS logo
$this->i['left_start'] = ceil(max(86, $this->text_string_width($this->longest_row_identifier, $this->i['identifier_size']) * 1.1 + 12));
if ($this->column_heading_vertical) {
$top_identifier_height = round($this->text_string_width($this->longest_column_identifier, $this->i['identifier_size']) * 1.1) + 12;
$table_identifier_width = $this->text_string_height($this->longest_column_identifier, $this->i['identifier_size']);
} else {
$top_identifier_height = $this->text_string_height($this->longest_column_identifier, $this->i['identifier_size']) + 8;
$table_identifier_width = round($this->text_string_width($this->longest_column_identifier, $this->i['identifier_size']) * 1.1) + 8;
}
// Needs to be at least 46px tall for the PTS logo
$top_identifier_height = max($top_identifier_height, 48);
if (defined('PHOROMATIC_TRACKER') || $this->is_multi_way) {
$extra_heading_height = round($this->text_string_height($this->longest_column_identifier, self::$c['size']['headers']) * 1.25);
$top_identifier_height += 6 + $extra_heading_height;
}
$this->i['top_heading_height'] = 8;
if ($this->graph_title != null) {
$this->i['top_heading_height'] += round(self::$c['size']['headers'] + count($this->graph_sub_titles) * (self::$c['size']['sub_headers'] + 4));
}
$table_max_value_width = ceil($this->text_string_width($this->i['graph_max_value'], $this->i['identifier_size']) * 1.02) + 2;
$table_item_width = max($table_max_value_width, $table_identifier_width) + 2;
$table_width = max($table_item_width * count($this->columns), floor($this->text_string_width($this->graph_title, 12) / $table_item_width) * $table_item_width);
//$table_width = $table_item_width * count($this->columns);
$table_line_height = round($this->text_string_height($this->i['graph_max_value'], $this->i['identifier_size']) + 8);
$table_line_height_half = round($table_line_height / 2);
$table_height = $table_line_height * count($this->rows);
$table_proper_height = $this->i['top_heading_height'] + $table_height + $top_identifier_height;
$this->i['graph_width'] = $table_width + $this->i['left_start'];
$this->i['graph_height'] = round($table_proper_height + $table_line_height);
if (!empty($this->i['notes'])) {
$this->i['graph_height'] += $this->note_display_height();
}
// Do the actual work
$this->render_graph_pre_init();
$this->render_graph_init();
$this->svg_dom->add_element('rect', array('x' => 1, 'y' => 1, 'width' => $this->i['graph_width'] - 1, 'height' => $this->i['graph_height'] - 1, 'fill' => self::$c['color']['background'], 'stroke' => self::$c['color']['border'], 'stroke-width' => 1));
// Start drawing
if ($this->i['left_start'] >= 170 && $top_identifier_height >= 90) {
$this->svg_dom->add_element('image', array('http_link' => 'http://www.phoronix-test-suite.com/', 'xlink:href' => 'https://openbenchmarking.org/static/images/pts-160x83.png', 'x' => round($this->i['left_start'] / 2 - 80), 'y' => round($top_identifier_height / 2 - 41.5 + $this->i['top_heading_height']), 'width' => 160, 'height' => 83));
} else {
$this->svg_dom->add_element('image', array('http_link' => 'http://www.phoronix-test-suite.com/', 'xlink:href' => 'https://openbenchmarking.org/static/images/pts-80x42.png', 'x' => round($this->i['left_start'] / 2 - 40), 'y' => round($top_identifier_height / 2 - 21 + $this->i['top_heading_height']), 'width' => 80, 'height' => 42));
}
// Draw the vertical table lines
$v = round(($top_identifier_height + $table_height) / 2 + $this->i['top_heading_height']);
$table_columns_end = $this->i['left_start'] + $table_item_width * count($this->columns);
$this->svg_dom->draw_svg_line($this->i['left_start'], $v, $table_columns_end, $v, self::$c['color']['body'], $table_height + $top_identifier_height, array('stroke-dasharray' => $table_item_width . ',' . $table_item_width));
if ($table_columns_end < $this->i['graph_width']) {
$this->svg_dom->add_element('rect', array('x' => $table_columns_end, 'y' => $this->i['top_heading_height'], 'width' => $this->i['graph_width'] - $table_columns_end, 'height' => $table_height + $top_identifier_height, 'fill' => self::$c['color']['body_light']));
}
// Background horizontal
$this->svg_dom->draw_svg_line(round($table_columns_end / 2), $top_identifier_height + $this->i['top_heading_height'], round($table_columns_end / 2), $table_proper_height, self::$c['color']['body_light'], $table_columns_end, array('stroke-dasharray' => $table_line_height . ',' . $table_line_height));
// Draw the borders
$this->svg_dom->draw_svg_line($this->i['left_start'], $v, $table_columns_end + ($table_columns_end < $this->i['graph_width'] ? $table_item_width : 0), $v, self::$c['color']['border'], $table_height + $top_identifier_height, array('stroke-dasharray' => '1,' . ($table_item_width - 1)));
// Heading
if ($this->graph_title != null) {
$this->svg_dom->add_element('rect', array('x' => 1, 'y' => 1, 'width' => $this->i['graph_width'] - 2, 'height' => $this->i['top_heading_height'], 'fill' => self::$c['color']['main_headers']));
$this->svg_dom->add_text_element($this->graph_title, array('x' => 5, 'y' => self::$c['size']['headers'] + 2, 'font-size' => self::$c['size']['headers'], 'fill' => self::$c['color']['background'], 'text-anchor' => 'start'));
foreach ($this->graph_sub_titles as $i => $sub_title) {
$vertical_offset = 16 + self::$c['size']['headers'] + $i * self::$c['size']['sub_headers'];
$this->svg_dom->add_text_element($sub_title, array('x' => 5, 'y' => $vertical_offset, 'font-size' => self::$c['size']['sub_headers'], 'fill' => self::$c['color']['background'], 'text-anchor' => 'start'));
}
$this->svg_dom->draw_svg_line(1, $this->i['top_heading_height'], $this->i['graph_width'] - 1, $this->i['top_heading_height'], self::$c['color']['border'], 1);
}
// Write the rows
$row = 1;
$g = $this->svg_dom->make_g(array('font-size' => $this->i['identifier_size'], 'font-weight' => 'bold', 'text-anchor' => 'end', 'fill' => self::$c['color']['text']));
foreach ($this->rows as $i => $row_string) {
if ($row_string instanceof pts_graph_ir_value == false) {
$row_string = new pts_graph_ir_value($row_string);
}
$v = round($top_identifier_height + $this->i['top_heading_height'] + $row * $table_line_height - 4);
$r = array('x' => $this->i['left_start'] - 2, 'y' => $v, 'fill' => self::$c['color']['text'], 'xlink:href' => $row_string->get_attribute('href'));
if ($row_string->get_attribute('alert')) {
$r['fill'] = self::$c['color']['alert'];
}
$this->svg_dom->add_text_element($row_string, $r, $g);
$row++;
}
// Write the identifiers
if (defined('PHOROMATIC_TRACKER') || $this->is_multi_way) {
$last_identifier = null;
$last_changed_col = 0;
$show_keys = array_keys($this->table_data);
array_push($show_keys, 'Temp: Temp');
$g1 = $this->svg_dom->make_g(array());
$g2 = $this->svg_dom->make_g(array('font-size' => self::$c['size']['axis_headers'], 'fill' => self::$c['color']['background'], 'font-weight' => 'bold', 'text-anchor' => 'middle'));
foreach ($show_keys as $current_col => $system_identifier) {
$identifier = pts_strings::colon_explode($system_identifier);
if (isset($identifier[0]) && $identifier[0] != $last_identifier) {
if ($current_col == $last_changed_col) {
$last_identifier = $identifier[0];
continue;
}
$paint_color = $this->get_paint_color($identifier[0]);
if ($this->i['top_heading_height'] > 0) {
$extra_heading_height = $this->i['top_heading_height'];
}
$x = $this->i['left_start'] + 1 + $last_changed_col * $table_item_width;
//.........这里部分代码省略.........
示例12: read_ati_overdrive
public static function read_ati_overdrive($attribute, $adapter = 0)
{
// Read ATI OverDrive information
// OverDrive supported in fglrx 8.52+ drivers
$value = false;
if ($amdconfig = self::find_amdconfig()) {
if ($attribute == 'Temperature') {
$info = shell_exec($amdconfig . ' --adapter=' . $adapter . ' --od-gettemperature 2>&1');
if (($start = strpos($info, 'Temperature -')) !== false) {
$info = substr($info, $start + 14);
$value = substr($info, 0, strpos($info, ' C'));
}
} else {
if ($attribute == 'FanSpeed') {
// Right now there is no standardized interface to get the fan speed through besides the pplib command
$info = shell_exec($amdconfig . ' --adapter=' . $adapter . ' --pplib-cmd \'get fanspeed 0\' 2>&1');
if (($start = strpos($info, 'Fan Speed:')) !== false) {
$info = substr($info, $start + 11);
$info = substr($info, 0, strpos($info, '%'));
if (is_numeric($info)) {
$value = $info;
}
}
} else {
$info = shell_exec($amdconfig . ' --adapter=' . $adapter . ' --od-getclocks 2>&1');
if (strpos($info, 'GPU') !== false) {
foreach (explode("\n", $info) as $line) {
$line_r = pts_strings::colon_explode($line);
if (count($line_r) == 2) {
$od_option = str_replace(' ', null, $line_r[0]);
if ($od_option == $attribute) {
$od_value = pts_strings::trim_spaces($line_r[1]);
$od_value = str_replace(array('%'), null, $od_value);
$od_value_r = explode(' ', $od_value);
$value = count($od_value_r) == 1 ? $od_value_r[0] : $od_value_r;
}
}
}
}
}
}
}
return $value;
}
示例13: remove_noisy_results
public function remove_noisy_results($threshold = 0.6)
{
if ($this->test_profile->get_display_format() != 'BAR_GRAPH') {
return false;
}
$is_multi_way = pts_render::multi_way_identifier_check($this->test_result_buffer->get_identifiers());
$keys = array_keys($this->test_result_buffer->buffer_items);
if ($is_multi_way) {
$key_sets = array();
foreach ($keys as $k) {
$identifier_r = pts_strings::trim_explode(': ', $this->test_result_buffer->buffer_items[$k]->get_result_identifier());
if (!isset($key_sets[$identifier_r[0]])) {
$key_sets[$identifier_r[0]] = array();
}
$key_sets[$identifier_r[0]][] = $k;
}
} else {
$key_sets = array($keys);
}
foreach ($key_sets as $keys) {
$jiggy_results = 0;
foreach ($keys as $k) {
$raw = $this->test_result_buffer->buffer_items[$k]->get_result_raw();
if (!empty($raw)) {
$raw = pts_math::standard_error(pts_strings::colon_explode($raw));
if ($raw > 10) {
$jiggy_results++;
}
}
}
if ($jiggy_results / count($keys) > $threshold) {
foreach ($keys as $k) {
unset($this->test_result_buffer->buffer_items[$k]);
}
}
}
return true;
}
示例14: result_file_to_result_table
public static function result_file_to_result_table(&$result_file, &$system_id_keys = null, &$result_object_index = -1, &$flag_delta_results = false, $extra_attributes = null)
{
$result_table = array();
$result_tests = array();
$result_counter = 0;
foreach ($result_file->get_system_identifiers() as $sys_identifier) {
$result_table[$sys_identifier] = null;
}
foreach ($result_file->get_result_objects($result_object_index) as $ri => $result_object) {
if ($result_object->test_profile->get_identifier() == null) {
continue;
}
if ($extra_attributes != null) {
if (isset($extra_attributes['reverse_result_buffer'])) {
$result_object->test_result_buffer->buffer_values_reverse();
}
if (isset($extra_attributes['normalize_result_buffer'])) {
if (isset($extra_attributes['highlight_graph_values']) && is_array($extra_attributes['highlight_graph_values']) && count($extra_attributes['highlight_graph_values']) == 1) {
$normalize_against = $extra_attributes['highlight_graph_values'][0];
} else {
$normalize_against = false;
}
$result_object->normalize_buffer_values($normalize_against);
}
}
if ($result_object_index != -1) {
if (is_array($result_object_index)) {
$result_tests[$result_counter] = new pts_graph_ir_value($result_object->get_arguments_description());
} else {
$result_tests[$result_counter] = new pts_graph_ir_value('Results');
}
} else {
$result_tests[$result_counter] = new pts_graph_ir_value($result_object->test_profile->get_title());
$result_tests[$result_counter]->set_attribute('title', $result_object->get_arguments_description());
if ($result_object->test_profile->get_identifier() != null) {
$result_tests[$result_counter]->set_attribute('href', 'http://openbenchmarking.org/test/' . $result_object->test_profile->get_identifier());
}
}
if ($result_object->test_profile->get_identifier() == null) {
if ($result_object->test_profile->get_display_format() == 'BAR_GRAPH') {
$result_tests[$result_counter]->set_attribute('alert', true);
foreach ($result_object->test_result_buffer->get_buffer_items() as $index => $buffer_item) {
$identifier = $buffer_item->get_result_identifier();
$value = $buffer_item->get_result_value();
$result_table[$identifier][$result_counter] = new pts_graph_ir_value($value, array('alert' => true));
}
$result_counter++;
}
continue;
}
switch ($result_object->test_profile->get_display_format()) {
case 'BAR_GRAPH':
$best_value = 0;
$worst_value = 0;
if (!defined('PHOROMATIC_TRACKER') && count($result_object->test_result_buffer->get_values()) > 1) {
switch ($result_object->test_profile->get_result_proportion()) {
case 'HIB':
$best_value = max($result_object->test_result_buffer->get_values());
$worst_value = min($result_object->test_result_buffer->get_values());
break;
case 'LIB':
$best_value = min($result_object->test_result_buffer->get_values());
$worst_value = max($result_object->test_result_buffer->get_values());
break;
}
}
$prev_value = 0;
$prev_identifier = null;
$prev_identifier_0 = null;
$values_in_buffer = $result_object->test_result_buffer->get_values();
sort($values_in_buffer);
$min_value_in_buffer = $values_in_buffer[0];
if ($min_value_in_buffer == 0) {
// Go through the values until something not 0, otherwise down in the code will be a divide by zero
for ($i = 1; $i < count($values_in_buffer) && $min_value_in_buffer == 0; $i++) {
$min_value_in_buffer = $values_in_buffer[$i];
}
}
$max_value_in_buffer = $values_in_buffer[count($values_in_buffer) - 1];
foreach ($result_object->test_result_buffer->get_buffer_items() as $index => $buffer_item) {
$identifier = $buffer_item->get_result_identifier();
$value = $buffer_item->get_result_value();
$raw_values = pts_strings::colon_explode($buffer_item->get_result_raw());
$percent_std = pts_math::set_precision(pts_math::percent_standard_deviation($raw_values), 2);
$std_error = pts_math::set_precision(pts_math::standard_error($raw_values), 2);
$delta = 0;
if (defined('PHOROMATIC_TRACKER')) {
$identifier_r = pts_strings::colon_explode($identifier);
if ($identifier_r[0] == $prev_identifier_0 && $prev_value != 0) {
$delta = pts_math::set_precision(abs(1 - $value / $prev_value), 4);
if ($delta > 0.02 && $delta > pts_math::standard_deviation($raw_values)) {
switch ($result_object->test_profile->get_result_proportion()) {
case 'HIB':
if ($value < $prev_value) {
$delta = 0 - $delta;
}
break;
case 'LIB':
if ($value > $prev_value) {
$delta = 0 - $delta;
//.........这里部分代码省略.........
示例15: renderGraphLines
protected function renderGraphLines()
{
$calculations_r = array();
$min_value = $this->graph_data[0][0];
$max_value = $this->graph_data[0][0];
$prev_value = $this->graph_data[0][0];
foreach (array_keys($this->graph_data) as $i_o) {
$paint_color = $this->get_special_paint_color(isset($this->graph_data_title[$i_o]) ? $this->graph_data_title[$i_o] : null);
$calculations_r[$paint_color] = array();
$point_counter = count($this->graph_data[$i_o]);
$regression_plots = array();
$poly_points = array();
for ($i = 0; $i < $point_counter; $i++) {
$value = $this->graph_data[$i_o][$i];
if ($value < 0 || $value == 0 && $this->graph_identifiers != null) {
// Draw whatever is needed of the line so far, since there is no result here
$this->draw_graph_line_process($poly_points, $paint_color, $regression_plots, $point_counter);
continue;
}
$identifier = isset($this->graph_identifiers[$i]) ? $this->graph_identifiers[$i] : null;
$std_error = isset($this->graph_data_raw[$i_o][$i]) ? pts_math::standard_error(pts_strings::colon_explode($this->graph_data_raw[$i_o][$i])) : 0;
$data_string = isset($this->graph_data_title[$i_o]) ? $this->graph_data_title[$i_o] . ($identifier ? ' @ ' . $identifier : null) . ': ' . $value : null;
$value_plot_top = $this->i['graph_top_end'] + 1 - ($this->i['graph_max_value'] == 0 ? 0 : round($value / $this->i['graph_max_value'] * ($this->i['graph_top_end'] - $this->i['top_start'])));
$px_from_left = round($this->i['left_start'] + $this->i['identifier_width'] * ($i + (count($this->graph_identifiers) > 1 ? 1 : 0)));
if ($value > $max_value) {
$max_value = $value;
} else {
if ($value < $min_value) {
$min_value = $value;
}
}
if ($px_from_left > $this->i['graph_left_end']) {
break;
}
if ($value_plot_top >= $this->i['graph_top_end']) {
$value_plot_top = $this->i['graph_top_end'] - 1;
}
array_push($poly_points, array($px_from_left, $value_plot_top, $data_string, $std_error));
if (isset($this->d['regression_marker_threshold']) && $this->d['regression_marker_threshold'] > 0 && $i > 0 && abs(1 - $value / $prev_value) > $this->d['regression_marker_threshold']) {
$regression_plots[$i - 1] = $prev_identifier . ': ' . $prev_value;
$regression_plots[$i] = $identifier . ': ' . $value;
}
array_push($calculations_r[$paint_color], $value);
$prev_identifier = $identifier;
$prev_value = $value;
}
$this->draw_graph_line_process($poly_points, $paint_color, $regression_plots, $point_counter);
}
}