本文整理汇总了PHP中pts_strings::trim_explode方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_strings::trim_explode方法的具体用法?PHP pts_strings::trim_explode怎么用?PHP pts_strings::trim_explode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_strings
的用法示例。
在下文中一共展示了pts_strings::trim_explode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($identifier = null)
{
$this->struct = array('external-dependencies' => array('name' => null, 'package_manager' => null, 'aliases' => array(), 'packages' => array()));
if (PTS_IS_CLIENT) {
$xml = PTS_EXDEP_PATH . 'xml/' . $identifier . '-packages.xml';
$xml_parser = new nye_XmlReader($xml);
$this->struct['external-dependencies']['name'] = $xml_parser->getXMLValue('PhoronixTestSuite/ExternalDependencies/Information/Name');
$this->struct['external-dependencies']['package_manager'] = $xml_parser->getXMLValue('PhoronixTestSuite/ExternalDependencies/Information/PackageManager');
$generic_package = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ExternalDependencies/Package/GenericName');
$distro_package = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ExternalDependencies/Package/PackageName');
$file_check = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ExternalDependencies/Package/FileCheck');
$arch_specific = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ExternalDependencies/Package/ArchitectureSpecific');
$os_version_specific = $xml_parser->getXMLArrayValues('PhoronixTestSuite/ExternalDependencies/Package/VersionSpecific');
$os_version = phodevi::read_property('system', 'os-version');
foreach (array_keys($generic_package) as $i) {
if (empty($generic_package[$i])) {
continue;
}
$os_version_compliant = empty($os_version_specific[$i]) || in_array($os_version, pts_strings::comma_explode($os_version_specific[$i]));
if ($os_version_compliant == false) {
continue;
}
$this->struct['external-dependencies']['packages'][$generic_package[$i]] = $this->get_package_format($distro_package[$i], $file_check[$i], $arch_specific[$i]);
}
$aliases = $xml_parser->getXMLValue('PhoronixTestSuite/ExternalDependencies/Information/Aliases');
if ($aliases != null) {
$aliases = pts_strings::trim_explode(',', $aliases);
foreach ($aliases as $alias) {
if ($alias != null) {
$this->struct['external-dependencies']['aliases'][] = $alias;
}
}
}
}
}
示例2: get_contained_test_result_objects
public function get_contained_test_result_objects()
{
$test_result_objects = array();
$test_names = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Test');
$sub_modes = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Mode');
$sub_arguments = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Arguments');
$sub_arguments_description = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Description');
$override_test_options = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/OverrideTestOptions');
for ($i = 0; $i < count($test_names); $i++) {
$obj = pts_types::identifier_to_object($test_names[$i]);
if ($obj instanceof pts_test_profile) {
// Check for test profile values to override
$override_options = array();
if (!empty($override_test_options[$i])) {
foreach (explode(';', $override_test_options[$i]) as $override_string) {
$override_segments = pts_strings::trim_explode('=', $override_string);
if (count($override_segments) == 2 && !empty($override_segments[0]) && !empty($override_segments[1])) {
$override_options[$override_segments[0]] = $override_segments[1];
}
}
}
switch ($sub_modes[$i]) {
case 'BATCH':
$option_output = pts_test_run_options::batch_user_options($obj);
break;
case 'DEFAULTS':
$option_output = pts_test_run_options::default_user_options($obj);
break;
default:
$option_output = array(array($sub_arguments[$i]), array($sub_arguments_description[$i]));
break;
}
foreach (array_keys($option_output[0]) as $x) {
if ($override_options != null) {
$test_profile->set_override_values($override_options);
}
$test_result = new pts_test_result($obj);
$test_result->set_used_arguments($option_output[0][$x]);
$test_result->set_used_arguments_description($option_output[1][$x]);
array_push($test_result_objects, $test_result);
}
} else {
if ($obj instanceof pts_test_suite) {
foreach ($obj->get_contained_test_result_objects() as $test_result) {
array_push($test_result_objects, $test_result);
}
}
}
}
return $test_result_objects;
}
示例3: get_supported_devices
public static function get_supported_devices()
{
if (phodevi::is_linux()) {
//TODO write network_usage_linux function
// $iface_list = shell_exec("ls -1 /sys/class/net | grep -v lo");
// $iface_array = explode("\n", $iface_list);
//
// return $iface_array;
return NULL;
}
if (phodevi::is_bsd() || phodevi::is_macosx()) {
$iface_list = shell_exec("ifconfig -lu | tr ' ' '\n' | grep -v 'lo0'");
$iface_array = pts_strings::trim_explode(" ", $iface_list);
return $iface_array;
}
return NULL;
}
示例4: clear_iqr_outlier_results
public static function clear_iqr_outlier_results(&$test_result_buffer)
{
$is_multi_way = pts_render::multi_way_identifier_check($test_result_buffer->get_identifiers());
if ($is_multi_way) {
$group_values = array();
$group_keys = array();
foreach ($test_result_buffer->buffer_items as $key => &$buffer_item) {
$identifier_r = pts_strings::trim_explode(': ', $buffer_item->get_result_identifier());
if (!isset($group_values[$identifier_r[1]])) {
$group_values[$identifier_r[1]] = array();
$group_keys[$identifier_r[1]] = array();
}
array_push($group_values[$identifier_r[1]], $buffer_item->get_result_value());
array_push($group_keys[$identifier_r[1]], $key);
}
foreach ($group_values as $group_key => $values) {
// From: http://www.mathwords.com/o/outlier.htm
$fqr = pts_math::first_quartile($values);
$tqr = pts_math::third_quartile($values);
$iqr_cut = ($tqr - $fqr) * 1.5;
$bottom_cut = $fqr - $iqr_cut;
$top_cut = $tqr + $iqr_cut;
foreach ($group_keys[$group_key] as $key) {
$value = $test_result_buffer->buffer_items[$key]->get_result_value();
if ($value > $top_cut || $value < $bottom_cut) {
unset($test_result_buffer->buffer_items[$key]);
}
}
}
} else {
// From: http://www.mathwords.com/o/outlier.htm
$values = $test_result_buffer->get_values();
$fqr = pts_math::first_quartile($values);
$tqr = pts_math::third_quartile($values);
$iqr_cut = ($tqr - $fqr) * 1.5;
$bottom_cut = $fqr - $iqr_cut;
$top_cut = $tqr + $iqr_cut;
foreach ($test_result_buffer->buffer_items as $key => &$buffer_item) {
$value = $buffer_item->get_result_value();
if ($value > $top_cut || $value < $bottom_cut) {
unset($test_result_buffer->buffer_items[$key]);
}
}
}
}
示例5: report_error
public function report_error($level, $message, $file, $line)
{
$error_string = '[' . $level . '] ';
if (strpos($message, PHP_EOL) === false) {
$error_string .= $message . ' ';
} else {
foreach (pts_strings::trim_explode(PHP_EOL, $message) as $line_count => $line_string) {
$error_string .= $line_string . PHP_EOL . str_repeat(' ', strlen($level) + 3);
}
}
if ($file != null) {
$error_string .= 'in ' . basename($file, '.php');
}
if ($line != 0) {
$error_string .= ':' . $line;
}
$this->log($error_string);
}
示例6: 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;
}
示例7: normalize_buffer_values
public function normalize_buffer_values($normalize_against = false)
{
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();
}
array_push($key_sets[$identifier_r[0]], $k);
}
} else {
$key_sets = array($keys);
}
foreach ($key_sets as $keys) {
if ($this->test_profile->get_result_proportion() == 'LIB') {
// Invert values for LIB
foreach ($keys as $k) {
$this->test_result_buffer->buffer_items[$k]->reset_result_value(1 / $this->test_result_buffer->buffer_items[$k]->get_result_value());
}
}
$divide_value = -1;
if ($normalize_against != false) {
foreach ($keys as $k) {
if ($is_multi_way && strpos($this->test_result_buffer->buffer_items[$k]->get_result_identifier(), ': ' . $normalize_against) !== false) {
// This allows it to just normalize against part of the string
$divide_value = $this->test_result_buffer->buffer_items[$k]->get_result_value();
break;
} else {
if ($this->test_result_buffer->buffer_items[$k]->get_result_identifier() == $normalize_against) {
$divide_value = $this->test_result_buffer->buffer_items[$k]->get_result_value();
break;
}
}
}
}
if ($divide_value == -1) {
foreach ($keys as $k) {
if ($this->test_result_buffer->buffer_items[$k]->get_result_value() < $divide_value || $divide_value == -1) {
$divide_value = $this->test_result_buffer->buffer_items[$k]->get_result_value();
}
}
}
if ($divide_value != 0) {
foreach ($keys as $k) {
$normalized = pts_math::set_precision($this->test_result_buffer->buffer_items[$k]->get_result_value() / $divide_value, max(3, $this->result_precision));
$this->test_result_buffer->buffer_items[$k]->reset_result_value($normalized);
$this->test_result_buffer->buffer_items[$k]->reset_raw_value(0);
}
}
}
$this->test_profile->set_result_proportion('HIB');
$this->test_profile->set_result_scale('Relative Performance');
return true;
}
示例8: executable_in_path
public static function executable_in_path($executable, $ignore_paths_with = false)
{
static $cache = null;
if (!isset($cache[$executable]) || $ignore_paths_with) {
$paths = pts_strings::trim_explode(phodevi::is_windows() ? ';' : ':', ($path = pts_client::read_env('PATH')) == false ? '/usr/local/bin:/usr/bin:/usr/sbin:/bin' : $path);
$executable_path = false;
foreach ($paths as $path) {
$path = pts_strings::add_trailing_slash($path);
if (is_executable($path . $executable)) {
if ($ignore_paths_with && stripos($path, $ignore_paths_with) !== false) {
continue;
}
$executable_path = $path . $executable;
break;
}
}
if ($ignore_paths_with) {
// Don't cache calls using the $ignore_paths_with parameter
return $executable_path;
}
$cache[$executable] = $executable_path;
}
return $cache[$executable];
}
示例9: generic_sub_heading
public function generic_sub_heading($string)
{
if (!empty($string)) {
// To generate the 'Phoronix Test Suite' heading string if not already done so
pts_client::$display->generic_heading(null, false);
foreach (pts_strings::trim_explode(PHP_EOL, $string) as $line_string) {
echo $this->tab . $line_string . PHP_EOL;
}
}
}
示例10: parse_equal_delimited_file
public static function parse_equal_delimited_file($file, $key)
{
$return_value = false;
foreach (explode("\n", pts_file_io::file_get_contents($file)) as $build_line) {
list($descriptor, $value) = pts_strings::trim_explode('=', $build_line);
if ($descriptor == $key) {
$return_value = $value;
break;
}
}
return $return_value;
}
示例11: read_sensors
public static function read_sensors($attributes)
{
// Read LM_Sensors
$value = false;
if (isset(phodevi::$vfs->sensors)) {
$sensors = phodevi::$vfs->sensors;
$sensors_lines = explode("\n", $sensors);
$attributes = pts_arrays::to_array($attributes);
for ($j = 0; $j < count($attributes) && empty($value); $j++) {
$attribute = $attributes[$j];
for ($i = 0; $i < count($sensors_lines) && $value == false; $i++) {
$line = pts_strings::trim_explode(': ', $sensors_lines[$i]);
if (!isset($line[0])) {
continue;
}
$this_attribute = $line[0];
if ($this_attribute == $attribute) {
$this_remainder = trim(str_replace(array('+', '°'), ' ', $line[1]));
$this_value = substr($this_remainder, 0, strpos($this_remainder, ' '));
if (is_numeric($this_value) && $this_value > 0) {
$value = $this_value;
}
}
}
}
}
return $value;
}
示例12: process_environment_variables_string_to_set
public static function process_environment_variables_string_to_set($env_var_string)
{
if (!empty($env_var_string)) {
foreach (explode(';', $env_var_string) as $ev) {
if (strpos($ev, '=') != false) {
list($var, $value) = pts_strings::trim_explode('=', $ev);
pts_client::set_environment_variable($var, $value);
pts_module_manager::var_store_add($var, $value);
}
}
pts_module_manager::detect_modules_to_load();
}
}
示例13: points_of_possible_interest
public function points_of_possible_interest($threshold_level = 0.1)
{
$points_of_interest = array();
if ($this->test_profile->get_display_format() != 'BAR_GRAPH') {
return $points_of_interest;
}
$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) {
$prev_value = -1;
$prev_id = -1;
foreach ($keys as $k) {
$this_value = $this->test_result_buffer->buffer_items[$k]->get_result_value();
$this_id = $this->test_result_buffer->buffer_items[$k]->get_result_identifier();
if ($prev_value != -1 && $prev_id != -1) {
$d = abs($prev_value / $this_value - 1);
if ($d > $threshold_level) {
$points_of_interest[] = $this_id . ' - ' . $prev_id . ': ' . round($d * 100, 2) . '%';
}
}
$prev_value = $this_value;
$prev_id = $this_id;
}
}
return $points_of_interest;
}
示例14: 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;
}
}
}
}
}
}
}
}
}
//.........这里部分代码省略.........
示例15: buffer_values_to_percent
public function buffer_values_to_percent()
{
$is_multi_way = pts_render::multi_way_identifier_check($this->get_identifiers());
if ($is_multi_way) {
$group_values = array();
foreach ($this->buffer_items as &$buffer_item) {
$identifier_r = pts_strings::trim_explode(': ', $buffer_item->get_result_identifier());
if (!isset($group_values[$identifier_r[1]])) {
$group_values[$identifier_r[1]] = 0;
}
$group_values[$identifier_r[1]] += $buffer_item->get_result_value();
}
foreach ($this->buffer_items as &$buffer_item) {
$identifier_r = pts_strings::trim_explode(': ', $buffer_item->get_result_identifier());
$percent = pts_math::set_precision($buffer_item->get_result_value() / $group_values[$identifier_r[1]] * 100, 3);
$buffer_item->reset_result_value($percent);
}
} else {
$total_value = array_sum($this->get_values());
foreach ($this->buffer_items as &$buffer_item) {
$percent = pts_math::set_precision($buffer_item->get_result_value() / $total_value * 100, 3);
$buffer_item->reset_result_value($percent);
}
}
}