当前位置: 首页>>代码示例>>PHP>>正文


PHP pts_math::percent_standard_deviation方法代码示例

本文整理汇总了PHP中pts_math::percent_standard_deviation方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_math::percent_standard_deviation方法的具体用法?PHP pts_math::percent_standard_deviation怎么用?PHP pts_math::percent_standard_deviation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pts_math的用法示例。


在下文中一共展示了pts_math::percent_standard_deviation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: increase_run_count_check

 public function increase_run_count_check(&$test_results, $scheduled_times_to_run, $latest_test_run_time)
 {
     // First make sure this test doesn't take too long to run where we don't want dynamic handling
     if (floor($latest_test_run_time / 60) > $this->dynamic_run_count_on_length_or_less) {
         return false;
     }
     // Determine if results are statistically significant, otherwise up the run count
     $std_dev = pts_math::percent_standard_deviation($test_results->test_result_buffer->get_values());
     if ($std_dev >= $this->dynamic_run_count_std_deviation_threshold) {
         static $last_run_count = 128;
         // just a number that should always cause the first check below to be true
         static $run_std_devs;
         $times_already_ran = $test_results->test_result_buffer->get_count();
         if ($times_already_ran <= $last_run_count) {
             // We're now onto a new test so clear out the array
             $run_std_devs = array();
         }
         $last_run_count = $times_already_ran;
         $run_std_devs[$last_run_count] = $std_dev;
         // If we haven't reached scheduled times to run x 2, increase count straight away
         if ($times_already_ran < $scheduled_times_to_run * 2) {
             return true;
         } else {
             if ($times_already_ran < $scheduled_times_to_run * 3) {
                 // More aggressive determination whether to still keep increasing the run count
                 $first_and_now_diff = pts_arrays::first_element($run_std_devs) - pts_arrays::last_element($run_std_devs);
                 // Increasing the run count at least looks to be helping...
                 if ($first_and_now_diff > pts_arrays::first_element($run_std_devs) / 2) {
                     // If we are at least making progress in the right direction, increase the run count some more
                     return true;
                 }
                 // TODO: could add more checks and take better advantage of the array of data to better determine if it's still worth increasing
             }
         }
     }
     // Check to see if there is an external/custom script to export the results to in determining whether results are valid
     if (($ex_file = $this->dynamic_run_count_export_script) != null && is_executable($ex_file) || is_executable($ex_file = PTS_USER_PATH . $this->dynamic_run_count_export_script)) {
         $exit_status = trim(shell_exec($ex_file . ' ' . $test_results->test_result_buffer->get_values_as_string() . ' > /dev/null 2>&1; echo $?'));
         switch ($exit_status) {
             case 1:
                 // Run the test again
                 return true;
             case 2:
                 // Results are bad, abandon testing and do not record results
                 return -1;
             case 0:
             default:
                 // Return was 0 or something else, results are valid, or was some other exit status
                 break;
         }
     }
     // No reason to increase the run count with none of the previous checks requesting otherwise
     return false;
 }
开发者ID:pchiruma,项目名称:phoronix-test-suite,代码行数:54,代码来源:pts_test_run_manager.php

示例2: process_user_config_external_hook_process

 protected static function process_user_config_external_hook_process($process, $cmd_value, $description_string = null, &$passed_obj = null)
 {
     if (!empty($cmd_value) && (is_executable($cmd_value) || ($cmd_value = pts_client::executable_in_path($cmd_value)))) {
         $descriptor_spec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
         $env_vars = array('PTS_EXTERNAL_TEST_HOOK' => $process);
         if ($passed_obj instanceof pts_test_result) {
             $env_vars['PTS_EXTERNAL_TEST_IDENTIFIER'] = $passed_obj->test_profile->get_identifier();
             $env_vars['PTS_EXTERNAL_TEST_RUN_POSITION'] = $passed_obj->test_result_buffer->get_count() + 1;
             $env_vars['PTS_EXTERNAL_TEST_RUN_COUNT'] = $passed_obj->test_profile->get_times_to_run();
             $env_vars['PTS_EXTERNAL_TEST_ARGS'] = $passed_obj->get_arguments();
             $env_vars['PTS_EXTERNAL_TEST_DESCRIPTION'] = $passed_obj->get_arguments_description();
             $env_vars['PTS_EXTERNAL_TEST_RESULT_SET'] = $passed_obj->test_result_buffer->get_values_as_string();
             $env_vars['PTS_EXTERNAL_TEST_RESULT'] = $passed_obj->get_result() != 0 ? $passed_obj->get_result() : pts_arrays::last_element($passed_obj->test_result_buffer->get_values());
             $env_vars['PTS_EXTERNAL_TEST_HASH'] = bin2hex($passed_obj->get_comparison_hash());
             $env_vars['PTS_EXTERNAL_TEST_STD_DEV_PERCENT'] = pts_math::percent_standard_deviation($passed_obj->test_result_buffer->get_values());
             if (is_file($passed_obj->test_profile->get_install_dir() . 'cache-share-' . PTS_INIT_TIME . '.pt2so')) {
                 // There's a cache share present
                 $env_vars['PTS_EXTERNAL_TEST_CACHE_SHARE'] = 1;
             }
         } else {
             if ($passed_obj instanceof pts_test_run_manager) {
                 $env_vars['PTS_EXTERNAL_TESTS_IN_QUEUE'] = implode(':', $passed_obj->get_tests_to_run_identifiers());
                 $env_vars['PTS_EXTERNAL_TEST_FILE_NAME'] = $passed_obj->get_file_name();
                 $env_vars['PTS_EXTERNAL_TEST_IDENTIFIER'] = $passed_obj->get_results_identifier();
             }
         }
         $description_string != null && pts_client::$display->test_run_instance_error($description_string);
         $proc = proc_open($cmd_value, $descriptor_spec, $pipes, null, $env_vars);
         $std_output = stream_get_contents($pipes[1]);
         $return_value = proc_close($proc);
         // If you want PTS to exit or something when your script returns !0, you could add an 'exit;' or whatever you want below
         // The contents of $std_output is anything that may have been written by your script, if you want it to be interpreted by anything in this module
         if ($return_value != 0) {
             return false;
         }
     }
     return true;
 }
开发者ID:ptzafrir,项目名称:phoronix-test-suite,代码行数:38,代码来源:result_notifier.php

示例3: 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;
//.........这里部分代码省略.........
开发者ID:pacificIT,项目名称:phoronix-test-suite,代码行数:101,代码来源:pts_ResultFileTable.php

示例4: test_run_instance_complete

 public function test_run_instance_complete(&$test_result)
 {
     if ($this->expected_trial_run_count > 1 && $this->trial_run_count_current >= $this->expected_trial_run_count) {
         $values = $test_result->test_result_buffer->get_values();
         if (count($values) > 1) {
             echo ($this->trial_run_count_current < 10 ? ' ' : null) . ' [Std. Dev: ' . pts_math::set_precision(pts_math::percent_standard_deviation($values), 2) . '%]';
         }
     }
 }
开发者ID:pchiruma,项目名称:phoronix-test-suite,代码行数:9,代码来源:pts_web_display_mode.php


注:本文中的pts_math::percent_standard_deviation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。