本文整理汇总了PHP中pts_strings::comma_explode方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_strings::comma_explode方法的具体用法?PHP pts_strings::comma_explode怎么用?PHP pts_strings::comma_explode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_strings
的用法示例。
在下文中一共展示了pts_strings::comma_explode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_download_object_list
public function generate_download_object_list($do_file_checks = true)
{
$download_xml_file = $this->test_profile->get_file_download_spec();
if ($download_xml_file != null) {
$xml_parser = new pts_test_downloads_nye_XmlReader($download_xml_file);
$package_url = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/URL');
$package_md5 = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/MD5');
$package_sha256 = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/SHA256');
$package_filename = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/FileName');
$package_filesize = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/FileSize');
$package_platform = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/PlatformSpecific');
$package_architecture = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/ArchitectureSpecific');
foreach (array_keys($package_url) as $i) {
if (!empty($package_platform[$i]) && $do_file_checks) {
$platforms = pts_strings::comma_explode($package_platform[$i]);
if (!in_array(phodevi::operating_system(), $platforms) && !(phodevi::is_bsd() && in_array('Linux', $platforms) && (pts_client::executable_in_path('kldstat') && strpos(shell_exec('kldstat -n linux 2>&1'), 'linux.ko') != false))) {
// This download does not match the operating system
continue;
}
}
if (!empty($package_architecture[$i]) && $do_file_checks) {
$architectures = pts_strings::comma_explode($package_architecture[$i]);
if (phodevi::cpu_arch_compatible($architectures) == false) {
// This download does not match the CPU architecture
continue;
}
}
$this->test_files[] = new pts_test_file_download($package_url[$i], $package_filename[$i], $package_filesize[$i], $package_md5[$i], $package_sha256[$i], $package_platform[$i], $package_architecture[$i]);
}
}
}
示例2: get_package_format
public function get_package_format($distro_package = null, $file_check = null, $arch_specific = null)
{
if (!is_array($arch_specific)) {
$arch_specific = pts_strings::comma_explode($arch_specific);
}
return array('os_package' => $distro_package, 'file_check' => $file_check, 'arch_specific' => $arch_specific);
}
示例3: __construct
public function __construct(&$result_object, &$result_file = null, $extra_attributes = null)
{
$max_count = 0;
if (!isset($extra_attributes['force_tracking_line_graph']) || !$extra_attributes['force_tracking_line_graph']) {
foreach ($result_object->test_result_buffer->buffer_items as &$buffer_item) {
/*
$r = pts_strings::comma_explode($buffer_item->get_result_raw());
$c = count($r);
foreach($r as $val)
{
echo $val;
}
*/
$values = pts_strings::comma_explode($buffer_item->get_result_value());
$buffer_item->reset_result_value($values);
$buffer_item->reset_raw_value(pts_strings::comma_explode($buffer_item->get_result_raw()));
$max_count = max($max_count, count($values));
}
}
//$extra_attributes['no_compact_results_var'] = true;
parent::__construct($result_object, $result_file, $extra_attributes);
$this->i['show_graph_key'] = true;
$this->i['show_background_lines'] = true;
$this->i['iveland_view'] = true;
$this->i['min_identifier_size'] = 6.5;
$this->i['plot_overview_text'] = isset($extra_attributes['no_overview_text']) == false;
$this->i['display_select_identifiers'] = false;
$this->i['hide_graph_identifiers'] = !isset($extra_attributes['force_tracking_line_graph']) || !$extra_attributes['force_tracking_line_graph'];
// XXX removed on 20 January from here: $this->is_multi_way_comparison &&
if (isset($extra_attributes['force_tracking_line_graph']) && $extra_attributes['force_tracking_line_graph'] && is_array($this->results)) {
// need to do compacting here
$this->test_result->test_result_buffer = new pts_test_result_buffer();
foreach ($this->results as $system => $results) {
$result_r = array();
$raw_r = array();
//$json_r = array();
foreach ($this->graph_identifiers as $d) {
$result_r[$d] = null;
$raw_r[$d] = null;
//$json_r[$d] = null;
}
foreach ($results as &$buffer_item) {
$result_r[$buffer_item->get_result_identifier()] = $buffer_item->get_result_value();
$raw_r[$buffer_item->get_result_identifier()] = $buffer_item->get_result_raw();
$json_r[$buffer_item->get_result_identifier()] = $buffer_item->get_result_json();
}
// add array_values($json_r)
$this->test_result->test_result_buffer->add_test_result($system, array_values($result_r), array_values($raw_r));
}
$max_count = count($this->graph_identifiers) + 1;
}
$this->max_count = $max_count;
}
示例4: add_test_profile
public function add_test_profile($test_profile)
{
$added = false;
if (($e = pts_client::read_env('SKIP_TESTS')) != false && (in_array($test_profile->get_identifier(false), pts_strings::comma_explode($e)) || in_array($test_profile->get_identifier(true), pts_strings::comma_explode($e)))) {
//pts_client::$display->test_install_error($test_profile->get_identifier() . ' is being skipped from installation.');
} else {
if (($e = pts_client::read_env('SKIP_TESTING_SUBSYSTEMS')) != false && in_array(strtolower($test_profile->get_test_hardware_type()), pts_strings::comma_explode(strtolower($e)))) {
//pts_client::$display->test_install_error($test_profile->get_identifier() . ' is being skipped from installation.');
} else {
$added = pts_arrays::unique_push($this->tests_to_install, new pts_test_install_request($test_profile));
}
}
return $added;
}
示例5: run
public static function run($args)
{
$result_file = new pts_result_file($args[0]);
$result_file_identifiers = $result_file->get_system_identifiers();
if (count($result_file_identifiers) < 2) {
echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
return false;
}
$extract_identifiers = pts_strings::comma_explode(pts_user_io::prompt_text_menu('Select the test run(s) to extract', $result_file_identifiers, true));
$remove_identifiers = array_diff($result_file_identifiers, $extract_identifiers);
$result_file->remove_run($remove_identifiers);
do {
echo PHP_EOL . 'Enter new result file to extract to: ';
$extract_to = pts_user_io::read_user_input();
$extract_to = pts_test_run_manager::clean_save_name($extract_to);
} while (empty($extract_to));
pts_client::save_test_result($extract_to . '/composite.xml', $result_file->get_xml());
pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $extract_to . '/index.html');
}
示例6: __pre_run_process
public static function __pre_run_process(&$test_run_manager)
{
self::$result_identifier = $test_run_manager->get_results_identifier();
self::$individual_monitoring = pts_module::read_variable('MONITOR_INDIVIDUAL') !== '0';
self::$to_monitor = array();
$to_show = pts_strings::comma_explode(pts_module::read_variable('MONITOR'));
if (pts_module::read_variable('PERFORMANCE_PER_WATT')) {
// We need to ensure the system power consumption is being tracked to get performance-per-Watt
pts_arrays::unique_push($to_show, 'sys.power');
self::$individual_monitoring = true;
echo PHP_EOL . 'To Provide Performance-Per-Watt Outputs.' . PHP_EOL;
}
$monitor_all = in_array('all', $to_show);
foreach (phodevi::supported_sensors() as $sensor) {
if ($monitor_all || in_array(phodevi::sensor_identifier($sensor), $to_show) || in_array('all.' . $sensor[0], $to_show)) {
array_push(self::$to_monitor, $sensor);
pts_module::save_file('logs/' . phodevi::sensor_identifier($sensor));
}
}
if (in_array('i915_energy', $to_show) && is_readable('/sys/kernel/debug/dri/0/i915_energy')) {
// For now the Intel monitoring is a special case separate from the rest
// of the unified sensor monitoring since we're not polling it every time but just pre/post test.
self::$monitor_i915_energy = true;
}
if (count(self::$to_monitor) > 0) {
echo PHP_EOL . 'Sensors To Be Logged:';
foreach (self::$to_monitor as &$sensor) {
echo PHP_EOL . ' - ' . phodevi::sensor_name($sensor);
}
echo PHP_EOL;
if (pts_module::read_variable('MONITOR_INTERVAL') != null) {
$proposed_interval = pts_module::read_variable('MONITOR_INTERVAL');
if (is_numeric($proposed_interval) && $proposed_interval >= 1) {
self::$sensor_monitoring_frequency = $proposed_interval;
}
}
// Pad some idling sensor results at the start
sleep(self::$sensor_monitoring_frequency * 8);
}
pts_module::pts_timed_function('pts_monitor_update', self::$sensor_monitoring_frequency);
}
示例7: 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;
}
示例8: run
public static function run($args)
{
$result = $args[0];
$result_file = new pts_result_file($result);
$result_file_identifiers = $result_file->get_system_identifiers();
if (count($result_file_identifiers) < 2) {
echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
return false;
}
$extract_identifiers = pts_strings::comma_explode(pts_user_io::prompt_text_menu('Select the test run(s) to extract', $result_file_identifiers, true));
$extract_selects = array();
foreach ($extract_identifiers as $extract_identifier) {
array_push($extract_selects, new pts_result_merge_select($result, $extract_identifier));
}
do {
echo PHP_EOL . 'Enter new result file to extract to: ';
$extract_to = pts_user_io::read_user_input();
$extract_to = pts_test_run_manager::clean_save_name($extract_to);
} while (empty($extract_to) || pts_result_file::is_test_result_file($extract_to));
$extract_result = call_user_func_array(array('pts_merge', 'merge_test_results'), $extract_selects);
pts_client::save_test_result($extract_to . '/composite.xml', $extract_result);
pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $extract_to . '/index.html');
}
示例9: prepare_sensor_parameters
private static function prepare_sensor_parameters()
{
$sensor_list = pts_strings::comma_explode(pts_module::read_variable('MONITOR'));
$to_monitor = array();
foreach ($sensor_list as $sensor) {
$sensor_split = pts_strings::trim_explode('.', $sensor);
// Set 'all' from the beginning (eg. all.cpu.frequency) as the last
// element (cpu.frequency.all). As sensor parameters are also supported
// now, it's handy to mark that we want to include all sensors of specified
// type (cpu.all) or just all supported parameters of specified sensor
// (cpu.frequency.all).
if ($sensor_split[0] === 'all') {
$sensor_split[] = 'all';
array_shift($sensor_split);
}
$type =& $sensor_split[0];
$name =& $sensor_split[1];
$parameter =& $sensor_split[2];
if (empty($to_monitor[$type][$name])) {
$to_monitor[$type][$name] = array();
}
if ($parameter !== NULL) {
$to_monitor[$type][$name][] = $parameter;
}
}
return $to_monitor;
}
示例10: get_architecture_array
public function get_architecture_array()
{
return pts_strings::comma_explode($this->architecture);
}
示例11: render_graph_process
public static function render_graph_process(&$result_object, &$result_file = null, $save_as = false, $extra_attributes = null)
{
if (isset($extra_attributes['sort_result_buffer'])) {
$result_object->test_result_buffer->sort_buffer_items();
}
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_file != null) {
// Cache the redundant words on identifiers so it's not re-computed on every graph
static $redundant_word_cache;
if (!isset($redundant_word_cache[$result_file->get_title()])) {
$redundant_word_cache[$result_file->get_title()] = pts_render::evaluate_redundant_identifier_words($result_file->get_system_identifiers());
}
if ($redundant_word_cache[$result_file->get_title()]) {
$result_object->test_result_buffer->auto_shorten_buffer_identifiers($redundant_word_cache[$result_file->get_title()]);
}
// COMPACT PROCESS
if (!isset($extra_attributes['compact_to_scalar']) && $result_object->test_profile->get_display_format() == 'LINE_GRAPH' && $result_file->get_system_count() > 10) {
// If there's too many lines being plotted on line graph, likely to look messy, so convert to scalar automatically
$extra_attributes['compact_to_scalar'] = true;
}
// XXX: removed || $result_file->is_results_tracker() from below and should be added
// Removing the command fixes cases like: 1210053-BY-MYRESULTS43
$result_identifiers = $result_object->test_result_buffer->get_identifiers();
if ($result_file->is_multi_way_comparison($result_identifiers, $extra_attributes) || isset($extra_attributes['compact_to_scalar']) || isset($extra_attributes['compact_scatter'])) {
if ((isset($extra_attributes['compact_to_scalar']) || false && $result_file->is_multi_way_comparison($result_identifiers, $extra_attributes)) && in_array($result_object->test_profile->get_display_format(), array('FILLED_LINE_GRAPH'))) {
// Convert multi-way line graph into horizontal box plot
if (true) {
$result_object->test_profile->set_display_format('HORIZONTAL_BOX_PLOT');
}
/* else // XXX commented out during PTS 6.0 development, TODO decide if to delete
{
// Turn a multi-way line graph into an averaged bar graph
$buffer_items = $result_object->test_result_buffer->get_buffer_items();
$result_object->test_result_buffer = new pts_test_result_buffer();
foreach($buffer_items as $buffer_item)
{
$values = pts_strings::comma_explode($buffer_item->get_result_value());
$avg_value = pts_math::set_precision(array_sum($values) / count($values), 2);
$j = null;
if(count($values) > 2)
{
$j['min-result'] = min($values);
$j['max-result'] = max($values);
if($j['min-result'] == $j['max-result'])
{
$json = null;
}
}
$result_object->test_result_buffer->add_test_result($buffer_item->get_result_identifier(), $avg_value, null, $j, $j['min-result'], $j['max-result']);
}
$result_object->test_profile->set_display_format('BAR_GRAPH');
} */
}
if ($result_object->test_profile->get_display_format() != 'PIE_CHART') {
$result_table = false;
pts_render::compact_result_file_test_object($result_object, $result_table, $result_file, $extra_attributes);
}
} else {
if (in_array($result_object->test_profile->get_display_format(), array('LINE_GRAPH'))) {
// Check to see for line graphs if every result is an array of the same result (i.e. a flat line for every result).
// If all the results are just flat lines, you might as well convert it to a bar graph
$buffer_items = $result_object->test_result_buffer->get_buffer_items();
$all_values_are_flat = false;
$flat_values = array();
foreach ($buffer_items as $i => $buffer_item) {
$unique_in_buffer = array_unique(explode(',', $buffer_item->get_result_value()));
$all_values_are_flat = count($unique_in_buffer) == 1;
if ($all_values_are_flat == false) {
break;
}
$flat_values[$i] = array_pop($unique_in_buffer);
}
if ($all_values_are_flat) {
$result_object->test_result_buffer = new pts_test_result_buffer();
foreach ($buffer_items as $i => $buffer_item) {
$result_object->test_result_buffer->add_test_result($buffer_item->get_result_identifier(), $flat_values[$i]);
}
$result_object->test_profile->set_display_format('BAR_GRAPH');
}
}
}
}
$display_format = $result_object->test_profile->get_display_format();
$bar_orientation = 'HORIZONTAL';
// default to horizontal bar graph
switch ($display_format) {
//.........这里部分代码省略.........
示例12: render_graph_process
//.........这里部分代码省略.........
break;
default:
if (isset($extra_attributes['graph_render_type'])) {
$requested_graph_type = $extra_attributes['graph_render_type'];
} else {
if (defined('GRAPH_RENDER_TYPE')) {
$requested_graph_type = GRAPH_RENDER_TYPE;
} else {
$requested_graph_type = null;
}
}
switch ($requested_graph_type) {
case 'CANDLESTICK':
$graph = new pts_CandleStickGraph($result_object, $result_file);
break;
case 'LINE_GRAPH':
$graph = new pts_LineGraph($result_object, $result_file);
break;
case 'FILLED_LINE_GRAPH':
$graph = new pts_FilledLineGraph($result_object, $result_file);
break;
default:
if ($bar_orientation == 'VERTICAL') {
$graph = new pts_VerticalBarGraph($result_object, $result_file);
} else {
$graph = new pts_HorizontalBarGraph($result_object, $result_file);
}
break;
}
break;
}
if (isset($extra_attributes['regression_marker_threshold'])) {
$graph->markResultRegressions($extra_attributes['regression_marker_threshold']);
}
if (isset($extra_attributes['set_alternate_view'])) {
$graph->setAlternateView($extra_attributes['set_alternate_view']);
}
if (isset($extra_attributes['sort_result_buffer_values'])) {
$result_object->test_result_buffer->buffer_values_sort();
if ($result_object->test_profile->get_result_proportion() == 'HIB') {
$result_object->test_result_buffer->buffer_values_reverse();
}
}
if (isset($extra_attributes['highlight_graph_values'])) {
$graph->highlight_values($extra_attributes['highlight_graph_values']);
}
if (isset($extra_attributes['force_simple_keys'])) {
$graph->override_i_value('force_simple_keys', true);
} else {
if (PTS_IS_CLIENT && pts_client::read_env('GRAPH_HIGHLIGHT') != false) {
$graph->highlight_values(pts_strings::comma_explode(pts_client::read_env('GRAPH_HIGHLIGHT')));
}
}
switch ($display_format) {
case 'LINE_GRAPH':
if (isset($extra_attributes['no_overview_text']) && $graph instanceof pts_LineGraph) {
$graph->plot_overview_text = false;
}
case 'FILLED_LINE_GRAPH':
case 'BAR_ANALYZE_GRAPH':
case 'SCATTER_PLOT':
//$graph->hideGraphIdentifiers();
foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
$graph->loadGraphValues(pts_strings::comma_explode($buffer_item->get_result_value()), $buffer_item->get_result_identifier());
$graph->loadGraphRawValues(pts_strings::comma_explode($buffer_item->get_result_raw()));
}
$scale_special = $result_object->test_profile->get_result_scale_offset();
if (!empty($scale_special) && count($ss = pts_strings::comma_explode($scale_special)) > 0) {
$graph->loadGraphIdentifiers($ss);
}
break;
case 'HORIZONTAL_BOX_PLOT':
// TODO: should be able to load pts_test_result_buffer_item objects more cleanly into pts_Graph
$identifiers = array();
$values = array();
foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
array_push($identifiers, $buffer_item->get_result_identifier());
array_push($values, pts_strings::comma_explode($buffer_item->get_result_value()));
}
$graph->loadGraphIdentifiers($identifiers);
$graph->loadGraphValues($values);
break;
default:
// TODO: should be able to load pts_test_result_buffer_item objects more cleanly into pts_Graph
$identifiers = array();
$values = array();
$raw_values = array();
foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
array_push($identifiers, $buffer_item->get_result_identifier());
array_push($values, $buffer_item->get_result_value());
array_push($raw_values, $buffer_item->get_result_raw());
}
$graph->loadGraphIdentifiers($identifiers);
$graph->loadGraphValues($values);
$graph->loadGraphRawValues($raw_values);
break;
}
self::report_test_notes_to_graph($graph, $result_object);
return $graph;
}
示例13: read_sensor
public function read_sensor()
{
// Graphics processor real/current frequency
$show_memory = false;
$core_freq = 0;
$mem_freq = 0;
if (phodevi::is_nvidia_graphics()) {
$nv_freq = phodevi_parser::read_nvidia_extension('GPUCurrentClockFreqs');
$nv_freq = pts_strings::comma_explode($nv_freq);
$core_freq = isset($nv_freq[0]) ? $nv_freq[0] : 0;
$mem_freq = isset($nv_freq[1]) ? $nv_freq[1] : 0;
} else {
if (phodevi::is_ati_graphics() && phodevi::is_linux()) {
$od_clocks = phodevi_linux_parser::read_ati_overdrive('CurrentClocks');
if (is_array($od_clocks) && count($od_clocks) >= 2) {
$core_freq = array_shift($od_clocks);
$mem_freq = array_pop($od_clocks);
}
} else {
if (phodevi::is_linux()) {
if (isset(phodevi::$vfs->radeon_pm_info)) {
// radeon_pm_info should be present with Linux 2.6.34+
foreach (pts_strings::trim_explode("\n", phodevi::$vfs->radeon_pm_info) as $pm_line) {
$pm_line = pts_strings::colon_explode($pm_line);
if (isset($pm_line[1])) {
list($descriptor, $value) = $pm_line;
} else {
continue;
}
switch ($descriptor) {
case 'current engine clock':
$core_freq = pts_arrays::first_element(explode(' ', $value)) / 1000;
break;
case 'current memory clock':
$mem_freq = pts_arrays::first_element(explode(' ', $value)) / 1000;
break;
}
}
if ($core_freq == null && ($x = strpos(phodevi::$vfs->radeon_pm_info, 'sclk: '))) {
$x = substr(phodevi::$vfs->radeon_pm_info, $x + strlen('sclk: '));
$x = substr($x, 0, strpos($x, ' '));
if (is_numeric($x)) {
if ($x > 1000) {
$x = $x / 100;
}
$core_freq = $x;
}
}
if ($mem_freq == null && ($x = strpos(phodevi::$vfs->radeon_pm_info, 'mclk: '))) {
$x = substr(phodevi::$vfs->radeon_pm_info, $x + strlen('mclk: '));
$x = substr($x, 0, strpos($x, ' '));
if (is_numeric($x)) {
if ($x > 1000) {
$x = $x / 100;
}
$mem_freq = $x;
}
}
} else {
if (is_file('/sys/class/drm/card0/gt_cur_freq_mhz')) {
$gt_cur_freq_mhz = pts_file_io::file_get_contents('/sys/class/drm/card0/gt_cur_freq_mhz');
if ($gt_cur_freq_mhz > 2) {
$core_freq = $gt_cur_freq_mhz;
}
} else {
if (is_file('/sys/class/drm/card0/device/performance_level')) {
$performance_level = pts_file_io::file_get_contents('/sys/class/drm/card0/device/performance_level');
$performance_level = explode(' ', $performance_level);
$core_string = array_search('core', $performance_level);
if ($core_string !== false && isset($performance_level[$core_string + 1])) {
$core_string = str_ireplace('MHz', null, $performance_level[$core_string + 1]);
if (is_numeric($core_string) && $core_string > $core_freq) {
$core_freq = $core_string;
}
}
$mem_string = array_search('memory', $performance_level);
if ($mem_string !== false && isset($performance_level[$mem_string + 1])) {
$mem_string = str_ireplace('MHz', null, $performance_level[$mem_string + 1]);
if (is_numeric($mem_string) && $mem_string > $mem_freq) {
$mem_freq = $mem_string;
}
}
} else {
if (isset(phodevi::$vfs->i915_cur_delayinfo)) {
$i915_cur_delayinfo = phodevi::$vfs->i915_cur_delayinfo;
$cagf = strpos($i915_cur_delayinfo, 'CAGF: ');
if ($cagf !== false) {
$cagf_mhz = substr($i915_cur_delayinfo, $cagf + 6);
$cagf_mhz = substr($cagf_mhz, 0, strpos($cagf_mhz, 'MHz'));
if (is_numeric($cagf_mhz)) {
$core_freq = $cagf_mhz;
}
}
}
}
}
}
}
}
}
//.........这里部分代码省略.........
示例14: monitor_count
public static function monitor_count()
{
// Report number of connected/enabled monitors
$monitor_count = 0;
// First try reading number of monitors from xdpyinfo
$monitor_count = count(phodevi_parser::read_xdpy_monitor_info());
if ($monitor_count == 0) {
// Fallback support for ATI and NVIDIA if phodevi_parser::read_xdpy_monitor_info() fails
if (phodevi::is_nvidia_graphics()) {
$enabled_displays = phodevi_parser::read_nvidia_extension('EnabledDisplays');
switch ($enabled_displays) {
case '0x00010000':
$monitor_count = 1;
break;
case '0x00010001':
$monitor_count = 2;
break;
default:
$monitor_count = 1;
break;
}
} else {
if (phodevi::is_ati_graphics() && phodevi::is_linux()) {
$amdpcsdb_enabled_monitors = phodevi_linux_parser::read_amd_pcsdb('SYSTEM/BUSID-*/DDX,EnableMonitor');
$amdpcsdb_enabled_monitors = pts_arrays::to_array($amdpcsdb_enabled_monitors);
foreach ($amdpcsdb_enabled_monitors as $enabled_monitor) {
foreach (pts_strings::comma_explode($enabled_monitor) as $monitor_connection) {
$monitor_count++;
}
}
} else {
$monitor_count = 1;
}
}
}
return $monitor_count;
}
示例15: gpu_stock_frequency
public static function gpu_stock_frequency()
{
// Graphics processor stock frequency
$core_freq = 0;
$mem_freq = 0;
if (phodevi::is_nvidia_graphics() && phodevi::is_macosx() == false) {
// GPUDefault3DClockFreqs is the default and does not show under/over-clocking
$clock_freqs_3d = pts_strings::comma_explode(phodevi_parser::read_nvidia_extension('GPU3DClockFreqs'));
$clock_freqs_current = pts_strings::comma_explode(phodevi_parser::read_nvidia_extension('GPUCurrentClockFreqs'));
if (is_array($clock_freqs_3d) && isset($clock_freqs_3d[1])) {
list($core_freq, $mem_freq) = $clock_freqs_3d;
}
if (is_array($clock_freqs_current) && isset($clock_freqs_current[1])) {
$core_freq = max($core_freq, $clock_freqs_current[0]);
$mem_freq = max($mem_freq, $clock_freqs_current[1]);
}
} else {
if (phodevi::is_ati_graphics() && phodevi::is_linux()) {
$od_clocks = phodevi_linux_parser::read_ati_overdrive('CurrentPeak');
if (is_array($od_clocks) && count($od_clocks) >= 2) {
list($core_freq, $mem_freq) = $od_clocks;
}
} else {
if (phodevi::is_linux()) {
$display_driver = phodevi::read_property('system', 'display-driver');
switch ($display_driver) {
case '':
case 'nouveau':
if (is_file('/sys/class/drm/card0/device/performance_level')) {
/*
EXAMPLE OUTPUTS:
memory 1000MHz core 500MHz voltage 1300mV fanspeed 100%
3: memory 333MHz core 500MHz shader 1250MHz fanspeed 100%
c: memory 333MHz core 500MHz shader 1250MHz
*/
$performance_level = pts_file_io::file_get_contents('/sys/class/drm/card0/device/performance_level');
$performance_level = explode(' ', $performance_level);
$core_string = array_search('core', $performance_level);
if ($core_string !== false && isset($performance_level[$core_string + 1])) {
$core_string = str_ireplace('MHz', null, $performance_level[$core_string + 1]);
if (is_numeric($core_string)) {
$core_freq = $core_string;
}
}
$mem_string = array_search('memory', $performance_level);
if ($mem_string !== false && isset($performance_level[$mem_string + 1])) {
$mem_string = str_ireplace('MHz', null, $performance_level[$mem_string + 1]);
if (is_numeric($mem_string)) {
$mem_freq = $mem_string;
}
}
} else {
if (is_file('/sys/class/drm/card0/device/pstate')) {
// pstate is present with Linux 3.13 as the new performance states on Fermi/Kepler
$performance_state = pts_file_io::file_get_contents('/sys/class/drm/card0/device/pstate');
$performance_level = substr($performance_state, 0, strpos($performance_state, ' *'));
if ($performance_level == null) {
// Method for Linux 3.17+
$performance_level = substr($performance_state, strpos($performance_state, 'AC: ') + 4);
if ($t = strpos($performance_level, PHP_EOL)) {
$performance_level = substr($performance_level, 0, $t);
}
} else {
// Method for Linux ~3.13 through Linux 3.16
$performance_level = substr($performance_level, strrpos($performance_level, ': ') + 2);
}
$performance_level = explode(' ', $performance_level);
$core_string = array_search('core', $performance_level);
if ($core_string !== false && isset($performance_level[$core_string + 1])) {
$core_string = str_ireplace('MHz', null, $performance_level[$core_string + 1]);
if (strpos($core_string, '-') !== false) {
// to work around a range of values, e.g.
// 0a: core 405-1032 MHz memory 1620 MHz AC DC *
$core_string = max(explode('-', $core_string));
}
if (is_numeric($core_string)) {
$core_freq = $core_string;
}
}
$mem_string = array_search('memory', $performance_level);
if ($mem_string !== false && isset($performance_level[$mem_string + 1])) {
$mem_string = str_ireplace('MHz', null, $performance_level[$mem_string + 1]);
if (strpos($mem_string, '-') !== false) {
// to work around a range of values, e.g.
// 0a: core 405-1032 MHz memory 1620 MHz AC DC *
$mem_string = max(explode('-', $mem_string));
}
if (is_numeric($mem_string)) {
$mem_freq = $mem_string;
}
}
}
}
if ($display_driver != null) {
break;
}
case 'radeon':
if (isset(phodevi::$vfs->radeon_pm_info)) {
// radeon_pm_info should be present with Linux 2.6.34+ but was changed with Linux 3.11 Radeon DPM
if (stripos(phodevi::$vfs->radeon_pm_info, 'default')) {
//.........这里部分代码省略.........