public static function run($r) { $compare_tests = array(); $compare_subsystems = array(); foreach ($r as $test_object) { $test_object = pts_types::identifier_to_object($test_object); if ($test_object instanceof pts_test_profile) { array_push($compare_tests, $test_object->get_identifier(false)); if (!isset($compare_subsystems[$test_object->get_test_hardware_type()])) { $compare_subsystems[$test_object->get_test_hardware_type()] = 1; } else { $compare_subsystems[$test_object->get_test_hardware_type()] += 1; } } } if (empty($compare_tests)) { $subsystem_under_test = pts_user_io::prompt_text_menu('Sub-System To Test', array('Processor', 'Graphics', 'Disk')); } else { arsort($compare_subsystems); $compare_subsystems = array_keys($compare_subsystems); $subsystem_under_test = array_shift($compare_subsystems); } $system_info = array_merge(phodevi::system_hardware(false), phodevi::system_software(false)); $to_include = array(); $to_exclude = array(); if (isset($system_info[$subsystem_under_test])) { $compare_component = $system_info[$subsystem_under_test]; } else { return; } switch ($subsystem_under_test) { case 'Processor': self::system_component_to_format($system_info, $to_include, array('OS', 'Compiler', 'Kernel', 'Motherboard'), true); break; case 'Graphics': self::system_component_to_format($system_info, $to_include, array('OS', 'Display Driver', 'OpenGL', 'Processor', 'Kernel', 'Desktop'), true); break; case 'OS': self::system_component_to_format($system_info, $to_include, array('Processor', 'Motherboard', 'Graphics', 'Disk'), true); self::system_component_to_format($system_info, $to_exclude, array('OS')); break; case 'Disk': self::system_component_to_format($system_info, $to_include, array('Processor', 'OS', 'Chipset', 'Motherboard', 'Kernel'), true); break; } $payload = array('subsystem_under_test' => $subsystem_under_test, 'component_under_test' => $compare_component, 'include_components' => implode(',', $to_include), 'exclude_components' => implode(',', $to_exclude), 'include_tests' => implode(',', $compare_tests)); echo PHP_EOL . 'Querying test data from OpenBenchmarking.org...' . PHP_EOL; $json = pts_openbenchmarking::make_openbenchmarking_request('auto_generate_comparison', $payload); $json = json_decode($json, true); if (isset($json['auto_compare']['public_ids']) && isset($json['auto_compare']['count']) && $json['auto_compare']['count'] > 0) { echo 'Found ' . $json['auto_compare']['count'] . ' comparable results on OpenBenchmarking.org with a ' . $json['auto_compare']['accuracy'] . '% accuracy.' . PHP_EOL; $compare_results = array(); foreach ($json['auto_compare']['public_ids'] as $public_id) { $result_xml = pts_openbenchmarking::clone_openbenchmarking_result($public_id, true); if ($result_xml) { $result_file = new pts_result_file($result_xml); $result_objects = $result_file->get_result_objects(); foreach ($result_objects as $i => &$result_object) { if (!empty($compare_tests)) { if (!in_array($result_object->test_profile->get_identifier(false), $compare_tests)) { unset($result_objects[$i]); } } else { if ($result_object->test_profile->get_test_hardware_type() != $subsystem_under_test) { unset($result_objects[$i]); } } } if (count($result_objects) == 0) { continue; } $result_file->override_result_objects($result_objects); array_push($compare_results, $result_file); } } if (count($compare_results) > 0) { $result_xml = pts_merge::merge_test_results_array($compare_results); if (count($compare_results) > 2) { $result_file = new pts_result_file($result_xml); $result_objects = $result_file->get_result_objects(); $system_count = $result_file->get_system_count(); $result_count = count($result_objects); $result_match_count = array(); if ($result_count > 3) { foreach ($result_objects as $i => &$result_object) { $result_match_count[$i] = $result_object->test_result_buffer->get_count(); } arsort($result_match_count); $biggest_size = pts_arrays::first_element($result_match_count); if ($biggest_size == $system_count || $biggest_size > 3) { foreach ($result_match_count as $key => $value) { if ($value < 2) { unset($result_objects[$key]); } } } $result_file->override_result_objects($result_objects); $result_xml = pts_merge::merge_test_results_array(array($result_file)); } } pts_client::save_test_result('auto-comparison/composite.xml', $result_xml); } } pts_test_installer::standard_install(array('auto-comparison')); pts_test_run_manager::standard_run(array('auto-comparison')); }
} } if ($composite_xml == null || sha1($composite_xml) != $COMPOSITE_XML_HASH) { $json['phoromatic']['error'] = 'XML Hash Mismatch'; echo json_encode($json); return false; } // VALIDATE $result_file = new pts_result_file($composite_xml); // Validate the XML if ($result_file->validate() == false) { $json['phoromatic']['error'] = 'XML Did Not Match Schema Definition'; echo json_encode($json); return false; } if ($result_file->get_title() == null || $result_file->get_system_count() == 0 || $result_file->get_test_count() == 0) { $json['phoromatic']['error'] = 'Invalid Result File'; echo json_encode($json); return false; } /*$Featured_Results = -1; $Featured = pts_result_file_analyzer::analyze_result_file_intent($result_file, $Featured_Results); if(!is_array($Featured)) { $Featured = array(null, null); }*/ // DETERMINE UNIQUE UPLOAD ID // IP = INET_ATON($_SERVER["REMOTE_ADDR"]); $stmt = phoromatic_server::$db->prepare('SELECT UploadID FROM phoromatic_results WHERE AccountID = :account_id ORDER BY UploadID DESC LIMIT 1'); $stmt->bindValue(':account_id', ACCOUNT_ID);
public static function render_page_process($PATH) { echo phoromatic_webui_header_logged_in(); $main = null; if (isset($PATH[0]) && !empty($PATH[0])) { ini_set('memory_limit', '4G'); if (isset($_POST['view_results_from_past']) && is_numeric($_POST['view_results_from_past'])) { $cut_duration = $_POST['view_results_from_past']; } else { $cut_duration = 21; } $stmt = phoromatic_server::$db->prepare('SELECT UploadID, UploadTime, ScheduleID, Trigger, SystemID FROM phoromatic_results WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY UploadTime DESC'); $stmt->bindValue(':account_id', $_SESSION['AccountID']); $stmt->bindValue(':schedule_id', $PATH[0]); $test_result_result = $stmt->execute(); $cutoff_time = is_numeric($cut_duration) ? strtotime('today -' . $cut_duration . ' days') : false; $show_only_latest_systems = array(); $result_files = array(); while ($test_result_result && ($row = $test_result_result->fetchArray())) { if ($cutoff_time !== false && strtotime($row['UploadTime']) < $cutoff_time) { break; } $composite_xml = phoromatic_server::phoromatic_account_result_path($_SESSION['AccountID'], $row['UploadID']) . 'composite.xml'; if (!is_file($composite_xml)) { continue; } // Add to result file $system_name = phoromatic_server::system_id_to_name($row['SystemID']) . ': ' . $row['Trigger']; array_push($result_files, new pts_result_merge_select($composite_xml, null, $system_name)); if (!isset($show_only_latest_systems[$_SESSION['AccountID'] . $row['SystemID']])) { $show_only_latest_systems[$_SESSION['AccountID'] . $row['SystemID']] = new pts_result_merge_select($composite_xml, null, $system_name); } } if (count($result_files) < 21) { $show_only_latest_systems = null; } $attributes = array('new_result_file_title' => phoromatic_schedule_id_to_name($row['ScheduleID'])); $result_file = new pts_result_file(null, true); $result_file->merge($result_files, $attributes); $extra_attributes = array('reverse_result_buffer' => true, 'force_simple_keys' => true, 'force_line_graph_compact' => true, 'force_tracking_line_graph' => true); if (isset($_POST['normalize_results']) && $_POST['normalize_results']) { $extra_attributes['normalize_result_buffer'] = true; } $main .= '<h1>' . $result_file->get_title() . '</h1>'; if ($result_file->get_system_count() == 1 || ($intent = pts_result_file_analyzer::analyze_result_file_intent($result_file, $intent, true))) { $table = new pts_ResultFileCompactSystemsTable($result_file, $intent); } else { $table = new pts_ResultFileSystemsTable($result_file); } $main .= '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>'; $table = new pts_ResultFileTable($result_file, $intent); $main .= '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>'; $main .= '<div id="pts_results_area">'; foreach ($result_file->get_result_objects(isset($_POST['show_only_changed_results']) ? 'ONLY_CHANGED_RESULTS' : -1) as $i => $result_object) { $main .= '<h2><a name="r-' . $i . '"></a><a name="' . $result_object->get_comparison_hash(true, false) . '"></a>' . $result_object->test_profile->get_title() . '</h2>'; $main .= '<p class="result_object">'; $main .= pts_render::render_graph_inline_embed($result_object, $result_file, $extra_attributes); $main .= '</p>'; } $main .= '</div>'; $right = '<form action="' . $_SERVER['REQUEST_URI'] . '" name="update_result_view" method="post">'; $right .= '<p>Compare results for the past: '; $right .= '<select name="view_results_from_past" id="view_results_from_past">'; $oldest_upload_time = strtotime(phoromatic_oldest_result_for_schedule($PATH[0])); $opts = array('Two Weeks' => 14, 'Three Weeks' => 21, 'One Month' => 30, 'Two Months' => 60, 'Quarter' => 90, 'Six Months' => 180, 'Year' => 365); foreach ($opts as $str_name => $time_offset) { if ($oldest_upload_time > time() - 86400 * $time_offset) { break; } $right .= '<option value="' . $time_offset . '">' . $str_name . '</option>'; } $right .= '<option value="all">All Results</option>'; $right .= '</select>'; $right .= '</p>'; $right .= '<p><input type="checkbox" name="normalize_results" value="1" ' . (isset($_POST['normalize_results']) ? 'checked="checked" ' : null) . '/> Normalize Results?</p>'; $right .= '<p><input type="submit" value="Refresh Results"></p></form>'; } else { if (empty($PATH)) { $main .= '<h1>Phoromatic Tracker</h1> <p>The Phoromatic Tracker will show result schedules that have enough uploaded test results from the associated systems to begin providing concise overviews of performance over time.</p> <div class="pts_phoromatic_info_box_area"> <ul> <li><h1>Trackable Results</h1></li>'; $stmt = phoromatic_server::$db->prepare('SELECT Title, ScheduleID, Description, RunTargetSystems, RunTargetGroups, RunAt, ActiveOn, (SELECT COUNT(*) FROM phoromatic_results WHERE ScheduleID = phoromatic_schedules.ScheduleID) AS UploadedResultCount FROM phoromatic_schedules WHERE AccountID = :account_id AND State >= 1 ORDER BY Title ASC'); $stmt->bindValue(':account_id', $_SESSION['AccountID']); $result = $stmt->execute(); $row = $result->fetchArray(); if ($row == false) { $main .= '<li class="light" style="text-align: center;">No Relevant Schedules Found</li>'; } else { do { if ($row['UploadedResultCount'] > ($row['RunTargetSystems'] + $row['RunTargetGroups'] + 1) * 7) { $stmt_tests = phoromatic_server::$db->prepare('SELECT COUNT(*) AS TestCount FROM phoromatic_schedules_tests WHERE AccountID = :account_id AND ScheduleID = :schedule_id ORDER BY TestProfile ASC'); $stmt_tests->bindValue(':account_id', $_SESSION['AccountID']); $stmt_tests->bindValue(':schedule_id', $row['ScheduleID']); $result_tests = $stmt_tests->execute(); $row_tests = $result_tests->fetchArray(); $test_count = !empty($row_tests) ? $row_tests['TestCount'] : 0; $group_count = empty($row['RunTargetGroups']) ? 0 : count(explode(',', $row['RunTargetGroups'])); $main .= '<a href="?tracker/' . $row['ScheduleID'] . '"><li>' . $row['Title'] . '<br /><table><tr><td>' . pts_strings::plural_handler(count(phoromatic_server::systems_associated_with_schedule($_SESSION['AccountID'], $row['ScheduleID'])), 'System') . '</td><td>' . pts_strings::plural_handler($group_count, 'Group') . '</td><td>' . pts_strings::plural_handler($test_count, 'Test') . '</td><td>' . pts_strings::plural_handler($row['UploadedResultCount'], 'Result') . ' Total</td></tr></table></li></a>'; } } while ($row = $result->fetchArray()); } $main .= '</ul> </div>'; $right = null; } } echo phoromatic_webui_main($main, $right); echo phoromatic_webui_footer(); }
$result_file->merge($result_files, $attributes); $extra_attributes = array(); $attribute_options = array('normalize_results' => 'normalize_result_buffer', 'sort_by_performance' => 'sort_result_buffer_values', 'sort_by_reverse' => 'reverse_result_buffer', 'sort_by_name' => 'sort_result_buffer', 'condense_comparison' => 'condense_multi_way'); foreach ($attribute_options as $web_var => $attr_var) { if (isset($_REQUEST[$web_var])) { $extra_attributes[$attr_var] = true; } } if (isset($_POST['transpose_comparison'])) { $result_file->invert_multi_way_invert(); } $intent = null; $main .= '<h1>' . $result_file->get_title() . '</h1>'; $main .= '<p>' . $result_file->get_description() . '</p>'; $main .= phoromatic_annotate_entry('RESULT', implode(',', $result_ids), 'TOP'); if ($result_file->get_system_count() == 1 || ($intent = pts_result_file_analyzer::analyze_result_file_intent($result_file, $intent, true))) { $table = new pts_ResultFileCompactSystemsTable($result_file, $intent); } else { $table = new pts_ResultFileSystemsTable($result_file); } $main .= '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>'; $table = new pts_ResultFileTable($result_file, $intent); $main .= '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>'; $main .= '<div id="pts_results_area">'; foreach ($result_file->get_result_objects(isset($_POST['show_only_changed_results']) ? 'ONLY_CHANGED_RESULTS' : -1) as $i => $result_object) { $main .= '<h2><a name="r-' . $i . '"></a><a name="' . $result_object->get_comparison_hash(true, false) . '"></a>' . $result_object->test_profile->get_title() . '</h2>'; $main .= phoromatic_annotate_entry('RESULT', implode(',', $result_ids), $result_object->get_comparison_hash(true, false)); $main .= '<p style="text-align: center; overflow: auto;">'; $main .= pts_render::render_graph_inline_embed($result_object, $result_file, $extra_attributes); $main .= '</p>'; }