本文整理汇总了PHP中phodevi::read_sensor_unit方法的典型用法代码示例。如果您正苦于以下问题:PHP phodevi::read_sensor_unit方法的具体用法?PHP phodevi::read_sensor_unit怎么用?PHP phodevi::read_sensor_unit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phodevi
的用法示例。
在下文中一共展示了phodevi::read_sensor_unit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run($r)
{
pts_client::$display->generic_heading('Supported Sensors');
foreach (phodevi::supported_sensors() as $sensor) {
echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL;
}
pts_client::$display->generic_heading('Unsupported Sensors');
foreach (phodevi::unsupported_sensors() as $sensor) {
echo '- ' . phodevi::sensor_name($sensor) . PHP_EOL;
}
echo PHP_EOL;
}
示例2: process_perf_per_watt
private static function process_perf_per_watt(&$result_file)
{
$sensor = array('sys', 'power');
$sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_identifier($sensor) . '.0', self::$individual_test_run_offsets[phodevi::sensor_identifier($sensor) . '.0']);
if (count($sensor_results) > 2 && self::$successful_test_run_request) {
// Copy the value each time as if you are directly writing the original data, each succeeding time in the loop the used arguments gets borked
$test_result = clone self::$successful_test_run_request;
$process_perf_per_watt = true;
$watt_average = array_sum($sensor_results) / count($sensor_results);
switch (phodevi::read_sensor_unit($sensor)) {
case 'Milliwatts':
$watt_average = $watt_average / 1000;
case 'Watts':
break;
default:
$process_perf_per_watt = false;
}
if ($process_perf_per_watt && $watt_average > 0 && $test_result->test_profile->get_display_format() == 'BAR_GRAPH') {
$test_result->test_profile->set_identifier(null);
//$test_result->set_used_arguments_description(phodevi::sensor_name('sys.power') . ' Monitor');
//$test_result->set_used_arguments(phodevi::sensor_name('sys.power') . ' ' . $test_result->get_arguments());
$test_result->test_result_buffer = new pts_test_result_buffer();
if ($test_result->test_profile->get_result_proportion() == 'HIB') {
$test_result->test_profile->set_result_scale($test_result->test_profile->get_result_scale() . ' Per Watt');
$test_result->test_result_buffer->add_test_result(self::$result_identifier, pts_math::set_precision($test_result->active->get_result() / $watt_average));
$result_file->add_result($test_result);
} else {
if ($test_result->test_profile->get_result_proportion() == 'LIB') {
$test_result->test_profile->set_result_proportion('HIB');
$test_result->test_profile->set_result_scale('Performance Per Watt');
$test_result->test_result_buffer->add_test_result(self::$result_identifier, pts_math::set_precision(1 / $test_result->active->get_result() / $watt_average));
$result_file->add_result($test_result);
}
}
self::$perf_per_watt_collection[] = $test_result->active->get_result();
}
}
}
示例3: read_sensor_results
public function read_sensor_results($sensor, $offset = 0)
{
$results = $this->read_sensor_data($sensor, $offset);
if (empty($results)) {
return false;
}
return array('id' => phodevi::sensor_identifier($sensor), 'name' => phodevi::sensor_name($sensor), 'results' => $results, 'unit' => phodevi::read_sensor_unit($sensor));
}
示例4: run
public static function run($r)
{
pts_openbenchmarking::refresh_repository_lists();
pts_client::$display->generic_heading('Interactive Benchmarking');
echo 'System Hardware:' . PHP_EOL . phodevi::system_hardware(true) . (phodevi::read_property('motherboard', 'serial-number') != null ? PHP_EOL . 'System Serial Number: ' . phodevi::read_property('motherboard', 'serial-number') : null) . PHP_EOL . PHP_EOL . PHP_EOL;
$reboot_on_exit = false;
do {
$options = array('RUN_TEST' => 'Run A Test', 'RUN_SUITE' => 'Run A Suite [A Collection Of Tests]', 'RUN_SYSTEM_TEST' => 'Run Complex System Test', 'SHOW_INFO' => 'Show System Hardware / Software Information', 'SHOW_SENSORS' => 'Show Auto-Detected System Sensors', 'SET_RUN_COUNT' => 'Set Test Run Repetition');
if (count(pts_client::saved_test_results()) > 0) {
$options['BACKUP_RESULTS_TO_USB'] = 'Backup Results To Media Storage';
}
$options['EXIT'] = $reboot_on_exit ? 'Exit & Reboot' : 'Exit';
$response = pts_user_io::prompt_text_menu('Select Task', $options, false, true);
switch ($response) {
case 'RUN_TEST':
$supported_tests = pts_openbenchmarking::available_tests();
$supported_tests = pts_types::identifiers_to_test_profile_objects($supported_tests, false, true);
$longest_title_length = 0;
foreach ($supported_tests as $i => &$test_profile) {
if ($test_profile->get_title() == null) {
unset($supported_tests[$i]);
continue;
}
$longest_title_length = max($longest_title_length, strlen($test_profile->get_title()));
}
$t = array();
foreach ($supported_tests as $i => &$test_profile) {
if ($test_profile instanceof pts_test_profile) {
$t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type());
}
}
$supported_tests = $t;
asort($supported_tests);
$tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true);
$tests_to_run = explode(',', $tests_to_run);
pts_test_installer::standard_install($tests_to_run);
$run_manager = new pts_test_run_manager(false, 2);
$run_manager->standard_run($tests_to_run);
if ($run_manager != false) {
pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
}
break;
case 'RUN_SUITE':
$possible_suites = pts_openbenchmarking::available_suites();
foreach (array_map('strtolower', pts_types::subsystem_targets()) as $subsystem) {
array_push($possible_suites, 'pts/' . $subsystem);
}
$suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true);
foreach (explode(',', $suites_to_run) as $suite_to_run) {
pts_test_installer::standard_install($suite_to_run);
$run_manager = new pts_test_run_manager(false, 2);
$run_manager->standard_run($suite_to_run);
}
break;
case 'SELECT_DRIVE_MOUNT':
self::select_drive_mount();
break;
case 'RUN_SYSTEM_TEST':
pts_client::$display->generic_heading('System Test');
$system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark');
pts_test_installer::standard_install($system_tests);
$run_manager = new pts_test_run_manager(false, 2);
$run_manager->standard_run($system_tests);
if ($run_manager != false) {
pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
}
break;
case 'SHOW_INFO':
pts_client::$display->generic_heading('System Software / Hardware 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;
break;
case 'SHOW_SENSORS':
pts_client::$display->generic_heading('Detected System Sensors');
foreach (phodevi::supported_sensors() as $sensor) {
echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL;
}
break;
case 'SET_RUN_COUNT':
$run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false);
putenv('FORCE_TIMES_TO_RUN=' . trim($run_count));
break;
case 'BACKUP_RESULTS_TO_USB':
pts_client::$display->generic_heading('Backing Up Test Results');
foreach (pts_file_io::glob('/media/*') as $media_dir) {
if (!is_writable($media_dir)) {
echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL;
continue;
}
echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL;
pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/');
break;
}
break;
}
echo PHP_EOL . PHP_EOL;
} while ($response != 'EXIT');
if ($reboot_on_exit) {
if (is_dir('/media/pts-auto-mount')) {
pts_file_io::delete('/media/pts-auto-mount/pts', null, true);
//.........这里部分代码省略.........
示例5: tick_thread
protected static function tick_thread()
{
static $last_phoromatic_log = 0;
while (true) {
$j = array();
$log_size = pts_client::$pts_logger->get_log_file_size();
if ($log_size != $last_phoromatic_log) {
$phoromatic_log = file_get_contents(pts_client::$pts_logger->get_log_file_location());
$last_phoromatic_log = $log_size;
$j['phoromatic']['client-log'] = $phoromatic_log;
}
foreach (phodevi::supported_sensors() as $sensor) {
$j['phoromatic']['stats']['sensors'][phodevi::sensor_name($sensor)] = array('value' => phodevi::read_sensor($sensor), 'unit' => phodevi::read_sensor_unit($sensor));
}
$j['phoromatic']['stats']['uptime'] = ceil(phodevi::system_uptime() / 60);
$server_response = phoromatic::upload_to_remote_server(array('r' => 'tick', 'j' => json_encode($j)));
$server_response = json_decode($server_response, true);
if ($server_response && isset($server_response['phoromatic']['tick_thread'])) {
switch ($server_response['phoromatic']['tick_thread']) {
case 'reboot':
if (pts_client::executable_in_path('reboot')) {
shell_exec('reboot');
}
break;
case 'halt-testing':
touch(PTS_USER_PATH . 'halt-testing');
break;
}
}
sleep(60);
}
}
示例6: __event_results_process
public static function __event_results_process(&$test_run_manager)
{
if (count(self::$perf_per_watt_collection) > 2) {
// Performance per watt overall
$avg = array_sum(self::$perf_per_watt_collection) / count(self::$perf_per_watt_collection);
$test_profile = new pts_test_profile();
$test_result = new pts_test_result($test_profile);
$test_result->test_profile->set_test_title('Meta Performance Per Watt');
$test_result->test_profile->set_identifier(null);
$test_result->test_profile->set_version(null);
$test_result->test_profile->set_result_proportion(null);
$test_result->test_profile->set_display_format('BAR_GRAPH');
$test_result->test_profile->set_result_scale('Performance Per Watt');
$test_result->test_profile->set_result_proportion('HIB');
$test_result->set_used_arguments_description('Performance Per Watt');
$test_result->set_used_arguments('Per-Per-Watt');
$test_result->test_result_buffer = new pts_test_result_buffer();
$test_result->test_result_buffer->add_test_result(self::$result_identifier, pts_math::set_precision($avg));
$test_run_manager->result_file->add_result($test_result);
}
echo PHP_EOL . 'Finishing System Sensor Monitoring Process' . PHP_EOL;
sleep(self::$sensor_monitoring_frequency * 4);
foreach (self::$to_monitor as $sensor) {
$sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_identifier($sensor));
pts_module::remove_file('logs/' . phodevi::sensor_identifier($sensor));
if (count($sensor_results) > 2 && self::$monitor_test_count > 1) {
$test_profile = new pts_test_profile();
$test_result = new pts_test_result($test_profile);
$test_result->test_profile->set_test_title(phodevi::sensor_name($sensor) . ' Monitor');
$test_result->test_profile->set_identifier(null);
$test_result->test_profile->set_version(null);
$test_result->test_profile->set_result_proportion(null);
$test_result->test_profile->set_display_format('LINE_GRAPH');
$test_result->test_profile->set_result_scale(phodevi::read_sensor_unit($sensor));
$test_result->set_used_arguments_description('Phoronix Test Suite System Monitoring');
$test_result->set_used_arguments(phodevi::sensor_identifier($sensor));
$test_result->test_result_buffer = new pts_test_result_buffer();
$test_result->test_result_buffer->add_test_result(self::$result_identifier, implode(',', $sensor_results), implode(',', $sensor_results), implode(',', $sensor_results), implode(',', $sensor_results));
$test_run_manager->result_file->add_result($test_result);
}
}
}
示例7: run
//.........这里部分代码省略.........
continue;
}
if ($is_moscow && pts_test_install_request::test_files_available_locally($test_profile) == false) {
// Don't show tests where files need to be downloaded
unset($supported_tests[$i]);
continue;
}
$longest_title_length = max($longest_title_length, strlen($test_profile->get_title()));
}
$t = array();
foreach ($supported_tests as $i => &$test_profile) {
if ($test_profile instanceof pts_test_profile) {
$t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type());
}
}
$supported_tests = $t;
asort($supported_tests);
$tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true);
$tests_to_run = explode(',', $tests_to_run);
pts_test_installer::standard_install($tests_to_run);
$run_manager = pts_test_run_manager::standard_run($tests_to_run, pts_c::defaults_mode | pts_c::auto_mode);
if ($run_manager != false) {
pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
}
break;
case 'RUN_SUITE':
$possible_suites = pts_openbenchmarking::available_suites();
foreach (array_map('strtolower', pts_types::subsystem_targets()) as $subsystem) {
array_push($possible_suites, 'pts/' . $subsystem);
}
$suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true);
foreach (explode(',', $suites_to_run) as $suite_to_run) {
pts_test_installer::standard_install($suite_to_run);
pts_test_run_manager::standard_run($suite_to_run, pts_c::defaults_mode | pts_c::auto_mode);
}
break;
case 'SELECT_DRIVE_MOUNT':
self::select_drive_mount();
break;
case 'RUN_SYSTEM_TEST':
pts_client::$display->generic_heading('System Test');
$system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark');
pts_test_installer::standard_install($system_tests);
$run_manager = pts_test_run_manager::standard_run($system_tests, pts_c::defaults_mode | pts_c::auto_mode);
if ($run_manager != false) {
pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
}
break;
case 'SHOW_INFO':
pts_client::$display->generic_heading('System Software / Hardware 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;
break;
case 'SHOW_SENSORS':
pts_client::$display->generic_heading('Detected System Sensors');
foreach (phodevi::supported_sensors() as $sensor) {
echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL;
}
break;
case 'SET_RUN_COUNT':
$run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false);
putenv('FORCE_TIMES_TO_RUN=' . trim($run_count));
break;
case 'BACKUP_RESULTS_TO_USB':
pts_client::$display->generic_heading('Backing Up Test Results');
if ($is_moscow) {
$drives = pts_file_io::glob('/dev/sd*');
sort($drives);
if (count($drives) > 0 && is_writable('/media/')) {
$select_drive = pts_user_io::prompt_text_menu('Select Drive / Partition To Save Results', $drives);
echo PHP_EOL . 'Attempting to mount: ' . $select_drive . PHP_EOL;
mkdir('/media/00-results-backup');
exec('mount ' . $select_drive . ' /media/00-results-backup');
}
}
foreach (pts_file_io::glob('/media/*') as $media_dir) {
if (!is_writable($media_dir)) {
echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL;
continue;
}
echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL;
pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/');
break;
}
if ($is_moscow && is_dir('/media/00-results-backup')) {
exec('umount /media/00-results-backup');
rmdir('/media/00-results-backup');
}
break;
}
echo PHP_EOL . PHP_EOL;
} while ($response != 'EXIT');
if ($reboot_on_exit) {
if (is_dir('/media/pts-auto-mount')) {
pts_file_io::delete('/media/pts-auto-mount/pts', null, true);
exec('umount /media/pts-auto-mount 2>&1');
}
exec('reboot');
}
}
示例8: __event_results_process
public static function __event_results_process(&$test_run_manager)
{
echo PHP_EOL . 'Finishing System Sensor Monitoring Process' . PHP_EOL;
sleep(self::$sensor_monitoring_frequency * 4);
foreach (self::$to_monitor as $sensor) {
$sensor_results = self::parse_monitor_log('logs/' . phodevi::sensor_identifier($sensor));
pts_module::remove_file('logs/' . phodevi::sensor_identifier($sensor));
if (count($sensor_results) > 2 && self::$monitor_test_count > 1) {
$test_profile = new pts_test_profile();
$test_result = new pts_test_result($test_profile);
$test_result->test_profile->set_test_title(phodevi::sensor_name($sensor) . ' Monitor');
$test_result->test_profile->set_identifier(null);
$test_result->test_profile->set_version(null);
$test_result->test_profile->set_result_proportion(null);
$test_result->test_profile->set_display_format('LINE_GRAPH');
$test_result->test_profile->set_result_scale(phodevi::read_sensor_unit($sensor));
$test_result->set_used_arguments_description('Phoronix Test Suite System Monitoring');
$test_result->set_used_arguments(phodevi::sensor_identifier($sensor));
$test_run_manager->result_file_writer->add_result_from_result_object_with_value_string($test_result, implode(',', $sensor_results), implode(',', $sensor_results));
}
}
}