本文整理汇总了PHP中pts_arrays类的典型用法代码示例。如果您正苦于以下问题:PHP pts_arrays类的具体用法?PHP pts_arrays怎么用?PHP pts_arrays使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了pts_arrays类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init_files
public static function init_files()
{
// Don't let the process run multiple times...
if (pts_config::$init_process_ran) {
return false;
}
pts_config::$init_process_ran = true;
// The main PTS user client config
pts_config::user_config_generate();
// Generate the graph config
$json_pre = null;
if (is_file(PTS_USER_PATH . 'graph-config.json')) {
$json_pre = file_get_contents(PTS_USER_PATH . 'graph-config.json');
} else {
if (PTS_IS_CLIENT && is_file($t = PTS_CORE_STATIC_PATH . 'graph-config-template-' . phodevi::read_property('system', 'vendor-identifier') . '.json')) {
$json_pre = file_get_contents($t);
} else {
if (is_file(PTS_CORE_STATIC_PATH . 'graph-config-template.json')) {
$json_pre = file_get_contents(PTS_CORE_STATIC_PATH . 'graph-config-template.json');
}
}
}
$json_graph = array();
pts_Graph::set_default_graph_values($json_graph);
if ($json_pre != null) {
$json_pre = json_decode($json_pre, true);
if (is_array($json_pre)) {
$json_graph = array_merge($json_graph, $json_pre);
}
}
pts_Graph::init_graph_config($json_graph);
file_put_contents(PTS_USER_PATH . 'graph-config.json', pts_arrays::json_encode_pretty_string($json_graph));
}
示例2: 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);
}
示例3: what_provides
public static function what_provides($files_needed)
{
$packages_needed = array();
foreach (pts_arrays::to_array($files_needed) as $file) {
if (pts_client::executable_in_path('apt-file')) {
if (!defined('APT_FILE_UPDATED')) {
shell_exec('apt-file update 2>&1');
define('APT_FILE_UPDATED', 1);
}
// Try appending common paths
if (strpos($file, '.h') !== false) {
$apt_provides = self::run_apt_file_provides('/usr/include/' . $file);
if ($apt_provides != null) {
$packages_needed[$file] = $apt_provides;
}
} else {
if (strpos($file, '.so') !== false) {
$apt_provides = self::run_apt_file_provides('/usr/lib/' . $file);
if ($apt_provides != null) {
$packages_needed[$file] = $apt_provides;
}
} else {
foreach (array('/usr/bin/', '/bin/', '/usr/sbin') as $possible_path) {
$apt_provides = self::run_apt_file_provides($possible_path . $file);
if ($apt_provides != null) {
$packages_needed[$file] = $apt_provides;
break;
}
}
}
}
}
}
return $packages_needed;
}
示例4: run
public static function run($r)
{
$to_run = array();
foreach (pts_types::identifiers_to_test_profile_objects($r, false, true) as $test_profile) {
pts_arrays::unique_push($to_run, $test_profile);
}
pts_test_run_manager::standard_run($to_run);
}
示例5: __construct
public function __construct($result_file)
{
$result_object = null;
parent::__construct($result_object, $result_file);
// System Identifiers
if ($result_file->is_multi_way_comparison()) {
// Multi way comparisons currently render the overview graph as blank
$this->skip_graph = true;
return;
}
$this->system_identifiers = $result_file->get_system_identifiers();
if (count($this->system_identifiers) < 2) {
// No point in generating this when there is only one identifier
$this->skip_graph = true;
return;
}
$result_objects = array();
$test_titles = array();
foreach ($result_file->get_result_objects() as $result_object) {
if ($result_object->test_profile->get_display_format() == 'BAR_GRAPH') {
array_push($result_objects, $result_object);
array_push($test_titles, $result_object->test_profile->get_title());
foreach ($result_object->test_result_buffer->buffer_items as &$buffer_item) {
pts_arrays::unique_push($this->graph_identifiers, $buffer_item->get_result_identifier());
}
}
}
$result_object_count = count($result_objects);
if ($result_object_count < 3) {
// No point in generating this if there aren't many tests
$this->skip_graph = true;
return;
}
$result_file->override_result_objects($result_objects);
// Test Titles
$this->i['identifier_size'] = 6.5;
$this->i['graph_width'] = 1000;
list($longest_title_width, $longest_title_height) = pts_svg_dom::estimate_text_dimensions(pts_strings::find_longest_string($test_titles), $this->i['identifier_size']);
$this->i['left_start'] += 20;
$this->graphs_per_row = min(count($this->system_identifiers) > 10 ? 6 : 10, floor(($this->i['graph_width'] - $this->i['left_start'] - $this->i['left_end_right']) / ($longest_title_width + 4)));
$this->graph_item_width = floor(($this->i['graph_width'] - $this->i['left_start'] - $this->i['left_end_right']) / $this->graphs_per_row);
$this->graph_row_count = ceil($result_object_count / $this->graphs_per_row);
$this->i['top_start'] += 20 + count($this->system_identifiers) / 3 * $this->i['identifier_size'];
$height = $this->i['top_start'] + $this->graph_row_count * ($this->graph_row_height + 15);
$this->graph_title = $result_file->get_title();
$this->graph_y_title = null;
$this->i['graph_proportion'] = 'HIB';
$this->i['show_background_lines'] = true;
$this->update_graph_dimensions($this->i['graph_width'], $height, true);
$this->result_file = $result_file;
return true;
}
示例6: read_hal_property
public static function read_hal_property($udi, $key)
{
$value = false;
if (pts_client::executable_in_path('hal-get-property')) {
foreach (pts_arrays::to_array($udi) as $udi_check) {
$value = trim(shell_exec('hal-get-property --udi ' . $udi_check . ' --key ' . $key . ' 2> /dev/null'));
if ($value != false) {
break;
}
}
}
return $value;
}
示例7: 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;
}
示例8: read_sysctl
public static function read_sysctl($desc)
{
// Read sysctl, used by *BSDs
$info = false;
if (pts_client::executable_in_path('sysctl')) {
$desc = pts_arrays::to_array($desc);
for ($i = 0; $i < count($desc) && empty($info); $i++) {
$output = shell_exec('sysctl ' . $desc[$i] . ' 2>&1');
if ((($point = strpos($output, ':')) > 0 || ($point = strpos($output, '=')) > 0) && strpos($output, 'unknown oid') === false && strpos($output, 'is invalid') === false && strpos($output, 'not available') === false) {
$info = trim(substr($output, $point + 1));
}
}
}
return $info;
}
示例9: image_file_to_gd
public static function image_file_to_gd($img_file)
{
$img = false;
switch (strtolower(pts_arrays::last_element(explode('.', $img_file)))) {
case 'tga':
$img = pts_image::imagecreatefromtga($img_file);
break;
case 'png':
$img = imagecreatefrompng($img_file);
break;
case 'jpg':
case 'jpeg':
$img = imagecreatefromjpeg($img_file);
break;
}
return $img;
}
示例10: __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);
}
示例11: run
public static function run($r)
{
pts_client::$display->generic_heading('System Information');
echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL;
echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL;
//
// Processor Information
//
$cpu_flags = phodevi_cpu::get_cpu_flags();
echo PHP_EOL . 'PROCESSOR:' . PHP_EOL . PHP_EOL;
echo 'Core Count: ' . phodevi_cpu::cpuinfo_core_count() . PHP_EOL;
echo 'Thread Count: ' . phodevi_cpu::cpuinfo_thread_count() . PHP_EOL;
echo 'Cache Size: ' . phodevi_cpu::cpuinfo_cache_size() . ' KB' . PHP_EOL;
echo 'Instruction Set Extensions: ' . phodevi_cpu::instruction_set_extensions() . PHP_EOL;
echo 'AES Encryption: ' . ($cpu_flags & phodevi_cpu::get_cpu_feature_constant('aes') ? 'YES' : 'NO') . PHP_EOL;
echo 'Energy Performance Bias: ' . ($cpu_flags & phodevi_cpu::get_cpu_feature_constant('epb') ? 'YES' : 'NO') . PHP_EOL;
echo 'Virtualization: ' . (phodevi_cpu::virtualization_technology() ? phodevi_cpu::virtualization_technology() : 'NO') . PHP_EOL;
// Other info
foreach (pts_arrays::to_array(pts_test_run_manager::pull_test_notes(true)) as $test_note_head => $test_note) {
echo ucwords(str_replace('-', ' ', $test_note_head)) . ': ' . $test_note . PHP_EOL;
}
}
示例12: what_provides
public static function what_provides($files_needed)
{
$packages_needed = array();
foreach (pts_arrays::to_array($files_needed) as $file) {
if (pts_client::executable_in_path('dnf')) {
$dnf_provides = self::run_dnf_provides($file);
if ($dnf_provides != null) {
$packages_needed[$file] = $dnf_provides;
} else {
// Try appending common paths
if (strpos($file, '.h') !== false) {
$dnf_provides = self::run_dnf_provides('/usr/include/' . $file);
if ($dnf_provides != null) {
$packages_needed[$file] = $dnf_provides;
}
} else {
if (strpos($file, '.so') !== false) {
$dnf_provides = self::run_dnf_provides('/usr/lib/' . $file);
if ($dnf_provides != null) {
$packages_needed[$file] = $dnf_provides;
}
} else {
foreach (array('/usr/bin/', '/bin/', '/usr/sbin') as $possible_path) {
$dnf_provides = self::run_dnf_provides($possible_path . $file);
if ($dnf_provides != null) {
$packages_needed[$file] = $dnf_provides;
break;
}
}
}
}
}
}
}
return $packages_needed;
}
示例13: compact_result_file_test_object
//.........这里部分代码省略.........
}
}
if ($is_tracking) {
$prev_date_r = explode(' ', $prev_date);
if (count($prev_date_r) == 2 && ctype_alpha($prev_date_r[0])) {
// This check should make it so when like testing every Ubuntu releases (Ubuntu 11.04, Ubuntu 11.10, etc) it's not in a line graph
$is_tracking = false;
}
} else {
if ($is_tracking == false && $sha1_short_count > 5) {
// It's probably actually tracking..... based upon Stefan's Wine 1.4 example on 15 March 2012
$is_tracking = true;
}
}
foreach (array_keys($days) as $day_key) {
$days[$day_key] = $systems;
}
$raw_days = $days;
$json_days = $days;
foreach ($mto->test_result_buffer->get_buffer_items() as $buffer_item) {
$identifier = array_map('trim', explode(':', $buffer_item->get_result_identifier()));
switch (count($identifier)) {
case 2:
$system = $identifier[$system_index];
$date = $identifier[$date_index];
break;
case 1:
$system = 0;
$date = $identifier[0];
break;
default:
return;
break;
}
$days[$date][$system] = $buffer_item->get_result_value();
$raw_days[$date][$system] = $buffer_item->get_result_raw();
$json_days[$date][$system] = $buffer_item->get_result_json();
if (!is_numeric($days[$date][$system])) {
return;
}
}
$mto->test_result_buffer = new pts_test_result_buffer();
$day_keys = array_keys($days);
if ($condense_multi_way) {
$mto->set_used_arguments_description($mto->get_arguments_description() . ' | Composite Of: ' . implode(' - ', array_keys($days)));
foreach (array_keys($systems) as $system_key) {
$sum = 0;
$count = 0;
foreach ($day_keys as $day_key) {
$sum += $days[$day_key][$system_key];
$count++;
}
$mto->test_result_buffer->add_test_result($system_key, $sum / $count);
}
} else {
$mto->test_profile->set_result_scale($mto->test_profile->get_result_scale() . ' | ' . implode(',', array_keys($days)));
if ($is_tracking && $buffer_count < 16 && $result_file && pts_result_file_analyzer::analyze_result_file_intent($result_file) == false) {
// It can't be a tracker if the result file is comparing hardware/software, etc
$is_tracking = false;
}
switch ($mto->test_profile->get_display_format()) {
//case 'HORIZONTAL_BOX_PLOT':
// $mto->test_profile->set_display_format('HORIZONTAL_BOX_PLOT_MULTI');
// break;
case 'SCATTER_PLOT':
break;
default:
$line_graph_type = 'LINE_GRAPH';
$mto->test_profile->set_display_format(!isset($extra_attributes['force_tracking_line_graph']) && (count($days) < 5 || $is_tracking == false && !isset($extra_attributes['force_line_graph_compact'])) ? 'BAR_ANALYZE_GRAPH' : $line_graph_type);
break;
}
foreach (array_keys($systems) as $system_key) {
$results = array();
$raw_results = array();
$json_results = array();
foreach ($day_keys as $day_key) {
array_push($results, $days[$day_key][$system_key]);
array_push($raw_results, $raw_days[$day_key][$system_key]);
pts_arrays::unique_push($json_results, $json_days[$day_key][$system_key]);
}
// TODO XXX: Make JSON data work for multi-way comparisons!
if (count($json_results) == 1) {
$json = array_shift($json_results);
} else {
$json = null;
}
$mto->test_result_buffer->add_test_result($system_key, implode(',', $results), implode(',', $raw_results), $json);
}
}
if ($result_table !== false) {
foreach (array_keys($systems) as $system_key) {
foreach ($day_keys as $day_key) {
if (!isset($result_table[$system_key][$day_key])) {
$result_table[$system_key][$day_key] = array();
}
array_push($result_table[$system_key][$day_key], $days[$day_key][$system_key], $raw_days[$day_key][$system_key]);
}
}
}
}
示例14: get_result_objects
public function get_result_objects($select_indexes = -1)
{
if ($this->result_objects == null) {
$this->result_objects = array();
foreach ($this->xml->Result as $result) {
array_push($this->result_objects, $this->get_result_object($result));
}
}
if ($select_indexes != -1 && $select_indexes !== null) {
$objects = array();
if ($select_indexes == 'ONLY_CHANGED_RESULTS') {
foreach ($this->result_objects as &$result) {
// Only show results where the variation was greater than or equal to 1%
if (abs($result->largest_result_variation(0.01)) >= 0.01) {
array_push($objects, $result);
}
}
} else {
foreach (pts_arrays::to_array($select_indexes) as $index) {
if (isset($this->result_objects[$index])) {
array_push($objects, $this->result_objects[$index]);
}
}
}
return $objects;
}
return $this->result_objects;
}
示例15: result_file_to_text
public static function result_file_to_text(&$result_file, $terminal_width = 80)
{
$result_output = null;
$result_output .= $result_file->get_title() . PHP_EOL;
$result_output .= $result_file->get_description() . PHP_EOL . PHP_EOL . PHP_EOL;
$system_identifiers = array();
$system_hardware = array();
$system_software = array();
foreach ($result_file->get_systems() as $system) {
array_push($system_identifiers, $system->get_identifier());
array_push($system_hardware, $system->get_hardware());
array_push($system_software, $system->get_software());
}
for ($i = 0; $i < count($system_identifiers); $i++) {
$result_output .= $system_identifiers[$i] . ': ' . PHP_EOL . PHP_EOL;
$result_output .= "\t" . $system_hardware[$i] . PHP_EOL . PHP_EOL . "\t" . $system_software[$i] . PHP_EOL . PHP_EOL;
}
$longest_identifier_length = strlen(pts_strings::find_longest_string($system_identifiers)) + 2;
foreach ($result_file->get_result_objects() as $result_object) {
$result_output .= trim($result_object->test_profile->get_title() . ' ' . $result_object->test_profile->get_app_version() . PHP_EOL . $result_object->get_arguments_description());
if ($result_object->test_profile->get_result_scale() != null) {
$result_output .= PHP_EOL . ' ' . $result_object->test_profile->get_result_scale();
}
foreach ($result_object->test_result_buffer as &$buffers) {
$max_value = 0;
$min_value = pts_arrays::first_element($buffers)->get_result_value();
foreach ($buffers as &$buffer_item) {
if ($buffer_item->get_result_value() > $max_value) {
$max_value = $buffer_item->get_result_value();
} else {
if ($buffer_item->get_result_value() < $min_value) {
$min_value = $buffer_item->get_result_value();
}
}
}
$longest_result = strlen($max_value) + 1;
foreach ($buffers as &$buffer_item) {
$val = $buffer_item->get_result_value();
if (stripos($val, ',') !== false) {
$vals = explode(',', $val);
$val = 'MIN: ' . min($vals) . ' / AVG: ' . round(array_sum($vals) / count($vals), 2) . ' / MAX: ' . max($vals);
}
$result_output .= PHP_EOL . ' ' . $buffer_item->get_result_identifier() . ' ';
$result_length_offset = $longest_identifier_length - strlen($buffer_item->get_result_identifier());
if ($result_length_offset > 0) {
$result_output .= str_repeat('.', $result_length_offset) . ' ';
}
$result_output .= $val;
if (is_numeric($val)) {
$result_output .= str_repeat(' ', $longest_result - strlen($val)) . '|';
$current_line_length = strlen(substr($result_output, strrpos($result_output, PHP_EOL) + 1)) + 1;
$result_output .= str_repeat('=', round($val / $max_value * ($terminal_width - $current_line_length)));
}
}
}
$result_output .= PHP_EOL . PHP_EOL;
}
return $result_output;
}