public static function run($args) { $result = $args[0]; $result_file = new pts_result_file($result); $result_file_identifiers = $result_file->get_system_identifiers(); if (count($result_file_identifiers) < 2) { echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL; return false; } $extract_selects = array(); echo PHP_EOL . 'Enter The New Order To Display The New Results, From Left To Right.' . PHP_EOL; do { $extract_identifier = pts_user_io::prompt_text_menu('Select the test run to be showed next', $result_file_identifiers); array_push($extract_selects, new pts_result_merge_select($result, $extract_identifier)); $old_identifiers = $result_file_identifiers; $result_file_identifiers = array(); foreach ($old_identifiers as $identifier) { if ($identifier != $extract_identifier) { array_push($result_file_identifiers, $identifier); } } } while (count($result_file_identifiers) > 0); $ordered_result = pts_merge::merge_test_results_array($extract_selects); pts_client::save_test_result($args[0] . '/composite.xml', $ordered_result); pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $args[0] . '/index.html'); }
public static function run($r) { $result = $r[0]; $result_file = new pts_result_file($result); $result_file_identifiers = $result_file->get_system_identifiers(); if (count($result_file_identifiers) < 2) { echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL; return false; } $remove_identifiers = explode(',', pts_user_io::prompt_text_menu('Select the test run(s) to remove', $result_file_identifiers, true)); $keep_identifiers = array(); foreach ($result_file_identifiers as $identifier) { if (!in_array($identifier, $remove_identifiers)) { array_push($keep_identifiers, $identifier); } } foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) { foreach ($remove_identifiers as $remove_identifier) { if (is_dir(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $remove_identifier)) { pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $remove_identifier, null, true); } } } $extract_select = new pts_result_merge_select($result, $keep_identifiers); $extract_result = pts_merge::merge_test_results($extract_select); pts_client::save_test_result($r[0] . '/composite.xml', $extract_result); pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html'); }
public static function run($r) { $identifier = $r[0]; $test_xml_files = pts_file_io::glob(PTS_SAVE_RESULTS_PATH . $identifier . '/test-*.xml'); if (count($test_xml_files) == 0) { echo PHP_EOL . 'No test XML data was found.' . PHP_EOL; return false; } pts_client::save_test_result($identifier . '/composite.xml', pts_merge::merge_test_results_array($test_xml_files)); pts_client::regenerate_graphs($identifier, 'The ' . $identifier . ' result file XML has been rebuilt.'); }
public static function run($args) { $result_files = array(); foreach ($args as $id) { $xml = pts_openbenchmarking::clone_openbenchmarking_result($id, true); array_push($result_files, new pts_result_file($xml)); } $writer = new pts_result_file_writer(null); pts_merge::merge_test_results_process($writer, $result_files); pts_client::save_test_result($args[0] . '/composite.xml', $writer->get_xml(), true); echo PHP_EOL . 'Result Saved To: ' . PTS_SAVE_RESULTS_PATH . $args[0] . '/composite.xml' . PHP_EOL; }
public static function run($args) { $base_file = $args[0]; do { $rand_file = rand(1000, 9999); $save_to = 'analyze-' . $rand_file . '/'; } while (is_dir(PTS_SAVE_RESULTS_PATH . $save_to)); $save_to .= 'composite.xml'; // Analyze Results $SAVED_RESULTS = pts_merge::generate_analytical_batch_xml($base_file); pts_client::save_test_result($save_to, $SAVED_RESULTS); echo 'Results Saved To: ' . PTS_SAVE_RESULTS_PATH . $save_to . PHP_EOL . PHP_EOL; pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . dirname($save_to) . '/index.html'); }
public static function run($args) { $result = $args[0]; $result_file = new pts_result_file($result); $result_file_identifiers = $result_file->get_system_identifiers(); if (count($result_file_identifiers) < 2) { echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL; return false; } $extract_selects = array(); echo PHP_EOL . 'Automatically sorting the results...' . PHP_EOL; sort($result_file_identifiers); foreach ($result_file_identifiers as $identifier) { array_push($extract_selects, new pts_result_merge_select($result, $identifier)); } $ordered_result = pts_merge::merge_test_results_array($extract_selects); pts_client::save_test_result($args[0] . '/composite.xml', $ordered_result); pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $args[0] . '/index.html'); }
public static function run($r) { $result = $r[0]; $result_file = new pts_result_file($result); $result_file_identifiers = $result_file->get_system_identifiers(); $rename_identifier = pts_user_io::prompt_text_menu('Select the test run to rename', $result_file_identifiers); $rename_identifier_new = pts_user_io::prompt_user_input('Enter the new identifier'); $merge_selects = array(); foreach ($result_file_identifiers as $identifier) { $this_merge_select = new pts_result_merge_select($result, $identifier); if ($identifier == $rename_identifier && $rename_identifier != $rename_identifier_new) { $this_merge_select->rename_identifier($rename_identifier_new); } array_push($merge_selects, $this_merge_select); } foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) { if (is_dir(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier)) { rename(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier, PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier_new); } } $extract_result = pts_merge::merge_test_results_array($merge_selects); pts_client::save_test_result($r[0] . '/composite.xml', $extract_result); pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html'); }
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')); }
public static function multi_way_identifier_check($identifiers, &$system_hardware = null, &$result_file = null) { /* Samples To Use For Testing: 1109026-LI-AMDRADEON57 */ $systems = array(); $targets = array(); $is_multi_way = true; $is_multi_way_inverted = false; $is_ordered = true; $prev_system = null; foreach ($identifiers as $identifier) { $identifier_r = explode(':', $identifier); if (count($identifier_r) != 2 || isset($identifier[14]) && $identifier[4] == '-' && $identifier[13] == ':') { // the later check will fix 0000-00-00 00:00 as breaking into date return false; } if (false && $is_ordered && $prev_system != null && $prev_system != $identifier_r[0] && isset($systems[$identifier_r[0]])) { // The results aren't ordered $is_ordered = false; if ($result_file == null) { return false; } } $prev_system = $identifier_r[0]; $systems[$identifier_r[0]] = !isset($systems[$identifier_r[0]]) ? 1 : $systems[$identifier_r[0]] + 1; $targets[$identifier_r[1]] = !isset($targets[$identifier_r[1]]) ? 1 : $targets[$identifier_r[1]] + 1; } if (false && $is_ordered == false && $is_multi_way) { // TODO: get the reordering code to work if ($result_file instanceof pts_result_file) { // Reorder the result file $to_order = array(); sort($identifiers); foreach ($identifiers as $identifier) { array_push($to_order, new pts_result_merge_select($result_file, $identifier)); } $ordered_xml = pts_merge::merge_test_results_array($to_order); $result_file = new pts_result_file($ordered_xml); $is_multi_way = true; } else { $is_multi_way = false; } } $is_multi_way_inverted = $is_multi_way && count($targets) > count($systems); /* if($is_multi_way) { if(count($systems) < 3 && count($systems) != count($targets)) { $is_multi_way = false; } } */ // TODO XXX: for now temporarily disable inverted multi-way check to decide how to rework it appropriately /* if($is_multi_way) { $targets_count = count($targets); $systems_count = count($systems); if($targets_count > $systems_count) { $is_multi_way_inverted = true; } else if(is_array($system_hardware)) { $hardware = array_unique($system_hardware); //$software = array_unique($system_software); if($targets_count != $systems_count && count($hardware) == $systems_count) { $is_multi_way_inverted = true; } else if(count($hardware) == ($targets_count * $systems_count)) { $is_multi_way_inverted = true; } } } */ // TODO: figure out what else is needed to reasonably determine if the result file is a multi-way comparison return $is_multi_way ? array($is_multi_way, $is_multi_way_inverted) : false; }
public static function save_result_file(&$result_file_writer, $save_name) { // Save the test file // TODO: clean this up with pts_client::save_test_result $j = 1; while (is_file(PTS_SAVE_RESULTS_PATH . $save_name . '/test-' . $j . '.xml')) { $j++; } $real_name = $save_name . '/test-' . $j . '.xml'; pts_client::save_test_result($real_name, $result_file_writer->get_xml()); if (!is_file(PTS_SAVE_RESULTS_PATH . $save_name . '/composite.xml')) { pts_client::save_test_result($save_name . '/composite.xml', file_get_contents(PTS_SAVE_RESULTS_PATH . $real_name), true, $result_file_writer->get_result_identifier()); } else { // Merge Results $merged_results = pts_merge::merge_test_results(file_get_contents(PTS_SAVE_RESULTS_PATH . $save_name . '/composite.xml'), file_get_contents(PTS_SAVE_RESULTS_PATH . $real_name)); pts_client::save_test_result($save_name . '/composite.xml', $merged_results, true, $result_file_writer->get_result_identifier()); } return $real_name; }
public static function render_page_process($PATH) { $main = null; if (isset($PATH[0])) { $upload_ids = explode(',', $PATH[0]); foreach ($upload_ids as $i => $upload_id) { if (isset($upload_id[5]) && substr($upload_id, 0, 2) == 'S:') { $t = explode(':', $upload_id); $stmt = phoromatic_server::$db->prepare('SELECT UploadID, UploadTime 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', $t[1]); $test_result_result = $stmt->execute(); $cutoff_time = is_numeric($t[2]) ? strtotime('today -' . $t[2] . ' days') : false; while ($test_result_row = $test_result_result->fetchArray()) { if ($cutoff_time !== false && strtotime($test_result_row['UploadTime']) < $cutoff_time) { break; } array_push($upload_ids, $test_result_row['UploadID']); } unset($upload_ids[$i]); } } $upload_ids = array_unique($upload_ids); $result_file = array(); $display_rows = array(); $system_types = array(); $schedule_types = array(); $trigger_types = array(); $upload_times = array(); $benchmark_tickets = array(); $xml_result_hash = array(); $tickets = array(); foreach ($upload_ids as $id) { $result_share_opt = phoromatic_server::read_setting('force_result_sharing') ? '1 = 1' : 'AccountID = (SELECT AccountID FROM phoromatic_account_settings WHERE LetOtherGroupsViewResults = "1" AND AccountID = phoromatic_results.AccountID)'; $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE PPRID = :pprid AND (AccountID = :account_id OR ' . $result_share_opt . ') LIMIT 1'); $stmt->bindValue(':pprid', $id); $stmt->bindValue(':account_id', $_SESSION['AccountID']); $result = $stmt->execute(); $row = $result->fetchArray(); if (false && empty($row)) { // TODO XXX // XXX this code is ultimately dead $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE AccountID = :account_id AND UploadID = :upload_id LIMIT 1'); $stmt->bindValue(':account_id', $_SESSION['AccountID']); $stmt->bindValue(':upload_id', $id); $result = $stmt->execute(); $row = $result->fetchArray(); } if (empty($row)) { continue; } $composite_xml = phoromatic_server::phoromatic_account_result_path($row['AccountID'], $row['UploadID']) . 'composite.xml'; if (!is_file($composite_xml)) { echo 'File Not Found: ' . $composite_xml; return false; } $display_rows[$composite_xml] = $row; pts_arrays::unique_push($benchmark_tickets, $row['BenchmarkTicketID']); pts_arrays::unique_push($upload_times, $row['UploadTime']); pts_arrays::unique_push($xml_result_hash, $row['XmlUploadHash']); pts_arrays::unique_push($system_types, $row['SystemID']); pts_arrays::unique_push($schedule_types, $row['ScheduleID']); pts_arrays::unique_push($trigger_types, $row['Trigger']); pts_arrays::unique_push($tickets, $row['BenchmarkTicketID']); // Update view counter $stmt_view = phoromatic_server::$db->prepare('UPDATE phoromatic_results SET TimesViewed = (TimesViewed + 1) WHERE AccountID = :account_id AND UploadID = :upload_id'); $stmt_view->bindValue(':account_id', $_SESSION['AccountID']); $stmt_view->bindValue(':upload_id', $row['UploadID']); $stmt_view->execute(); } $result_file_title = null; if (count($system_types) == 1) { $result_file_title = phoromatic_system_id_to_name($system_types[0]) . ' Tests'; } if (!empty($tickets)) { $system_name_format = 'ORIGINAL_DATA'; } else { if (count($trigger_types) == 1 && $trigger_types[0] != null && $benchmark_tickets[0] != null && count($display_rows) > 1) { $system_name_format = 'TRIGGER_AND_SYSTEM'; } else { if (empty($schedule_types[0])) { $system_name_format = 'ORIGINAL_DATA'; } else { if (count($display_rows) == 1) { $system_name_format = 'SYSTEM_NAME'; } else { if (count($schedule_types) == 1 && count($system_types) == 1) { $system_name_format = 'TRIGGER'; $result_file_title = phoromatic_schedule_id_to_name($schedule_types[0]); } else { if (count($schedule_types) == 1) { $system_name_format = 'TRIGGER_AND_SYSTEM'; } else { if (false && count($trigger_types) == 1) { // TODO XXX: this approach yields garbage strings generally without refining the selector // i.e. first make sure all the schedules match or are comparable $system_name_format = 'SYSTEM_AND_SCHEDULE'; } else { $system_name_format = null; } } } } } } } if (count($schedule_types) == 1 && $schedule_types[0] != 0) { self::$schedule_id = $schedule_types[0]; } foreach ($display_rows as $composite_xml => $row) { // $row['SystemID'] . ' ' . $row['ScheduleID'] . ' ' . $row['Trigger'] switch ($system_name_format) { case 'ORIGINAL_DATA': $system_name = null; break; case 'SYSTEM_NAME': $system_name = phoromatic_system_id_to_name($row['SystemID']); break; case 'TRIGGER': $system_name = $row['Trigger']; break; case 'TRIGGER_AND_SYSTEM': $system_name = phoromatic_system_id_to_name($row['SystemID']) . ': ' . $row['Trigger']; break; case 'SYSTEM_AND_SCHEDULE': $system_name = phoromatic_schedule_id_to_name($row['ScheduleID']) . ': ' . $row['Trigger']; break; default: $system_name = phoromatic_system_id_to_name($row['SystemID']) . ' - ' . phoromatic_schedule_id_to_name($row['ScheduleID']) . ' - ' . $row['Trigger']; } if ($system_name == null) { $rf = new pts_result_file($composite_xml); $identifiers = $rf->get_system_identifiers(); if (count($identifiers) == 1) { $system_name = $identifiers[0]; } } $system_name = str_replace('.SYSTEM', phoromatic_system_id_to_name($row['SystemID']), $system_name); $system_name = str_replace('.GROUP', phoromatic_account_id_to_group_name($row['AccountID']), $system_name); $system_variables = explode(';', phoromatic_server::system_id_variables($row['SystemID'], $row['AccountID'])); foreach ($system_variables as $var) { $var = explode('=', $var); if (count($var) == 2) { $system_name = str_replace('.' . $var[0], $var[1], $system_name); } } array_push($result_file, new pts_result_merge_select($composite_xml, null, $system_name)); } $writer = new pts_result_file_writer(null); $attributes = array('new_result_file_title' => $result_file_title); pts_merge::merge_test_results_process($writer, $result_file, $attributes); $result_file = new pts_result_file($writer->get_xml()); $extra_attributes = array(); if (isset($_GET['upload_to_openbenchmarking'])) { $ob_url = pts_openbenchmarking_client::upload_test_result($result_file, false); if ($ob_url) { header('Location: ' . $ob_url); } } $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'); $url_append = null; foreach ($attribute_options as $web_var => $attr_var) { if (isset($_REQUEST[$web_var])) { $extra_attributes[$attr_var] = true; $url_append .= '&' . $web_var . '=1'; } } if (isset($_POST['transpose_comparison'])) { $result_file->invert_multi_way_invert(); } $intent = null; if (isset($_GET['download']) && $_GET['download'] == 'csv') { $result_csv = pts_result_file_output::result_file_to_csv($result_file); header('Content-Description: File Transfer'); header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename=phoromatic-result.csv'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . strlen($result_csv)); ob_clean(); flush(); echo $result_csv; return; } else { if (isset($_GET['download']) && $_GET['download'] == 'txt') { $result_txt = pts_result_file_output::result_file_to_text($result_file); header('Content-Description: File Transfer'); header('Content-Type: application/txt'); header('Content-Disposition: attachment; filename=phoromatic-result.txt'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . strlen($result_txt)); ob_clean(); flush(); echo $result_txt; return; } else { if (isset($_GET['download']) && $_GET['download'] == 'pdf') { ob_start(); $_REQUEST['force_format'] = 'PNG'; // Force to PNG renderer $_REQUEST['svg_dom_gd_no_interlacing'] = true; // Otherwise FPDF will fail $tdir = pts_client::create_temporary_directory(); pts_client::generate_result_file_graphs($result_file, $tdir, $extra_attributes); $pdf = new pts_pdf_template($result_file->get_title(), null); $pdf->AddPage(); $pdf->Image(PTS_CORE_STATIC_PATH . 'images/pts-308x160.png', 69, 85, 73, 38); $pdf->Ln(120); $pdf->WriteStatementCenter('www.phoronix-test-suite.com'); $pdf->Ln(15); $pdf->WriteBigHeaderCenter($result_file->get_title()); $pdf->WriteText($result_file->get_description()); $pdf->AddPage(); $pdf->Ln(15); $identifiers = $result_file->get_system_identifiers(); $hardware_r = $result_file->get_system_hardware(); $software_r = $result_file->get_system_software(); $notes_r = $result_file->get_system_notes(); $tests = $result_file->get_test_titles(); $pdf->SetSubject($result_file->get_title() . ' Benchmarks'); $pdf->SetKeywords(implode(', ', $identifiers)); $pdf->WriteHeader('Test Systems:'); for ($i = 0; $i < count($identifiers); $i++) { $pdf->WriteMiniHeader($identifiers[$i]); $pdf->WriteText($hardware_r[$i]); $pdf->WriteText($software_r[$i]); } $pdf->AddPage(); $placement = 1; for ($i = 1; $i <= count($tests); $i++) { if (is_file($tdir . 'result-graphs/' . $i . '.png')) { $pdf->Ln(100); $pdf->Image($tdir . 'result-graphs/' . $i . '.png', 50, 40 + ($placement - 1) * 120, 120); } if ($placement == 2) { $placement = 0; if ($i != count($tests)) { $pdf->AddPage(); } } $placement++; } ob_get_clean(); $pdf->Output('phoromatic.pdf', 'I'); //pts_file_io::delete($tdir, null, true); return; } } } $main .= '<h1>' . $result_file->get_title() . '</h1>'; $main .= phoromatic_annotate_entry('RESULT', implode(',', $upload_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(',', $upload_ids), $result_object->get_comparison_hash(true, false)); $main .= '<p class="result_object">'; $main .= pts_render::render_graph_inline_embed($result_object, $result_file, $extra_attributes); $main .= '</p>'; } $main .= '</div>'; } else { // No result } $right = null; if (self::$schedule_id && !empty(self::$schedule_id)) { $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_schedules WHERE AccountID = :account_id AND ScheduleID = :schedule_id LIMIT 1'); $stmt->bindValue(':account_id', $_SESSION['AccountID']); $stmt->bindValue(':schedule_id', self::$schedule_id); $result = $stmt->execute(); $row = $result->fetchArray(); if (!empty($row)) { $right .= '<h3><a href="?schedules/' . $row['ScheduleID'] . '">' . $row['Title'] . '</a></h3>'; if (!empty($row['ActiveOn'])) { $right .= '<p align="center"><strong>' . phoromatic_schedule_activeon_string($row['ActiveOn'], $row['RunAt']) . '</strong></p>'; } $right .= '<p>Compare this result file to the latest results from the past: '; $right .= '<select name="view_results_from_past" id="view_results_from_past" onchange="phoromatic_jump_to_results_from(\'' . $row['ScheduleID'] . '\', \'view_results_from_past\', \'' . $PATH[0] . ',\');">'; $oldest_upload_time = strtotime(phoromatic_oldest_result_for_schedule(self::$schedule_id)); $opts = array('Week' => 7, 'Three Weeks' => 21, 'Month' => 30, '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>'; } } if (true) { $compare_results = array(); $hash_matches = 0; $ticket_matches = 0; $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE AccountID = :account_id AND ComparisonHash = :comparison_hash AND PPRID NOT IN (:pprid) ORDER BY UploadTime DESC LIMIT 12'); $stmt->bindValue(':account_id', $_SESSION['AccountID']); $stmt->bindValue(':comparison_hash', $result_file->get_contained_tests_hash(false)); $stmt->bindValue(':pprid', implode(',', $upload_ids)); $result = $stmt->execute(); while ($row = $result->fetchArray()) { $compare_results[$row['PPRID']] = $row; $hash_matches++; } foreach ($benchmark_tickets as $ticket_id) { $stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_results WHERE AccountID = :account_id AND BenchmarkTicketID = :ticket_id AND PPRID NOT IN (:pprid) ORDER BY UploadTime DESC LIMIT 12'); $stmt->bindValue(':account_id', $_SESSION['AccountID']); $stmt->bindValue(':ticket_id', $ticket_id); $stmt->bindValue(':pprid', implode(',', $upload_ids)); $result = $stmt->execute(); while ($row = $result->fetchArray()) { $compare_results[$row['PPRID']] = $row; $ticket_matches++; } } if (!empty($compare_results)) { $right .= '<hr /><h3>Compare Results</h3><form name="compare_similar_results" onsubmit="return false;"> <input type="hidden" value="' . implode(',', $upload_ids) . '" id="compare_similar_results_this" />'; foreach ($compare_results as &$row) { $right .= '<p><input type="checkbox" value="' . $row['PPRID'] . '" name="compare_results" /> ' . $row['Title'] . '<br /><em>' . phoromatic_system_id_to_name($row['SystemID'], $row['AccountID']) . '</em></p>'; } $right .= '<p><input type="submit" value="Compare Results" id="compare_results_submit" onclick="javascript:phoromatic_do_custom_compare_results(this); return false;" /></p></form>'; if ($ticket_matches > 3) { $right .= '<p><a href="/results/ticket/' . $ticket_id . '">Find All Matching Results</a>'; } else { if ($hash_matches > 3) { $right .= '<p><a href="/results/hash/' . $result_file->get_contained_tests_hash(false) . '">Find All Matching Results</a>'; } } } } if (count($upload_ids) > 1) { $checkbox_options = array('normalize_results' => 'Normalize Results', 'sort_by_performance' => 'Sort Results By Performance', 'sort_by_name' => 'Reverse Result By Identifier', 'sort_by_reverse' => 'Reverse Result Order', 'show_only_changed_results' => 'Show Only Results With Result Variation'); if ($result_file->is_multi_way_comparison()) { $checkbox_options['condense_comparison'] = 'Condense Comparison'; $checkbox_options['transpose_comparison'] = 'Transpose Comparison'; } $right .= '<form action="' . $_SERVER['REQUEST_URI'] . '" name="update_result_view" method="post"><hr /><h3>Result Analysis Options</h3><p align="left">' . PHP_EOL; foreach ($checkbox_options as $val => $name) { $right .= '<input type="checkbox" name="' . $val . '" value="1" ' . (isset($_POST[$val]) ? 'checked="checked" ' : null) . '/> ' . $name . '<br />'; } $right .= '<br /><input type="submit" value="Refresh Results"></p></form>'; } if (self::$schedule_id && !empty(self::$schedule_id) && $system_types[0] && $trigger_types[0]) { $stmt = phoromatic_server::$db->prepare('SELECT UserContextStep FROM phoromatic_system_context_logs WHERE AccountID = :account_id AND ScheduleID = :schedule_id AND SystemID = :system_id AND TriggerID = :trigger_id'); $stmt->bindValue(':account_id', $_SESSION['AccountID']); $stmt->bindValue(':system_id', $system_types[0]); $stmt->bindValue(':schedule_id', self::$schedule_id); $stmt->bindValue(':trigger_id', $trigger_types[0]); $result = $stmt->execute(); if ($row = $result->fetchArray()) { $right .= '<hr /><h3>User Context Logs</h3>'; do { $right .= '<p><a href="?logs/context/' . $system_types[0] . ',' . self::$schedule_id . ',' . base64_encode($trigger_types[0]) . '">' . $row['UserContextStep'] . '</a></p>'; } while ($row = $result->fetchArray()); } } $right .= '<hr /><h3>Result Export</h3>'; $right .= '<p><a href="/public.php?t=result&ut=' . implode(',', $upload_ids) . $url_append . '">Public Viewer</a></p>'; $right .= '<p><a href="?' . $_SERVER['QUERY_STRING'] . '/&download=pdf' . $url_append . '">Download As PDF</a></p>'; $right .= '<p><a href="?' . $_SERVER['QUERY_STRING'] . '/&download=csv">Download As CSV</a></p>'; $right .= '<p><a href="?' . $_SERVER['QUERY_STRING'] . '/&download=txt">Download As TEXT</a></p>'; $right .= '<p><a href="?' . $_SERVER['QUERY_STRING'] . '/&upload_to_openbenchmarking">Upload To OpenBenchmarking.org</a></p>'; if (is_file(phoromatic_server::phoromatic_account_result_path($_SESSION['AccountID'], $row['UploadID']) . 'system-logs.zip')) { $right .= '<hr /><p><a href="?logs/system/' . $row['UploadID'] . '">View System Logs</a></p>'; } echo phoromatic_webui_header_logged_in(); echo phoromatic_webui_main($main, phoromatic_webui_right_panel_logged_in($right)); echo phoromatic_webui_footer(); }
$result_file = array(); $triggers = array_splice($tracker['triggers'], 0, $cut_duration); foreach ($triggers as $trigger) { $results_for_trigger = glob(PATH_TO_EXPORTED_PHOROMATIC_DATA . '/' . $REQUESTED . '/' . $trigger . '/*/composite.xml'); if ($results_for_trigger == false) { continue; } foreach ($results_for_trigger as $composite_xml) { // Add to result file $system_name = basename(dirname($composite_xml)) . ': ' . $trigger; array_push($result_file, new pts_result_merge_select($composite_xml, null, $system_name)); } } $writer = new pts_result_file_writer(null); $attributes = array(); pts_merge::merge_test_results_process($writer, $result_file, $attributes); $result_file = new pts_result_file($writer->get_xml()); $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; } $intent = null; //$table = new pts_ResultFileTable($result_file, $intent); //echo '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>'; echo '<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) { if (stripos($result_object->get_arguments_description(), 'frame time') !== false) { continue; } echo '<h2><a name="r-' . $i . '"></a>' . $result_object->test_profile->get_title() . '</h2>'; //echo '<h3>' . $result_object->get_arguments_description() . '</h3>';
public static function run($args) { $result = $args[0]; $result_file = new pts_result_file($result); $result_file_identifiers = $result_file->get_system_identifiers(); if (count($result_file_identifiers) < 2) { echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL; return false; } $base_identifier = pts_user_io::prompt_text_menu('Select the base test run', $result_file_identifiers); $base_select = new pts_result_merge_select($result, $base_identifier); $compare_identifier = pts_user_io::prompt_text_menu('Select the test run to compare', $result_file_identifiers); $compare_select = new pts_result_merge_select($result, $compare_identifier); do { $extract_to = 'iqc-analyze-' . rand(100, 999); } while (is_dir(PTS_SAVE_RESULTS_PATH . $extract_to)); $extract_result = pts_merge::merge_test_results($base_select, $compare_select); pts_client::save_test_result($extract_to . '/composite.xml', $extract_result); $compare_file = new pts_result_file($extract_to); $result_file_writer = new pts_result_file_writer('Image Delta'); foreach ($compare_file->get_result_objects() as $result_object) { if ($result_object->test_profile->get_display_format() != 'IMAGE_COMPARISON') { continue; } $base_result = null; $compare_result = null; foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) { if ($buffer_item->get_result_identifier() == $base_identifier && $base_result == null) { $base_result = $buffer_item->get_result_value(); } else { if ($buffer_item->get_result_identifier() == $compare_identifier && $compare_result == null) { $compare_result = $buffer_item->get_result_value(); } } if ($compare_result != null && $base_result != null) { break; } } if ($compare_result == null || $base_result == null) { continue; } $base_img = imagecreatefromstring(base64_decode($base_result)); $compare_img = imagecreatefromstring(base64_decode($compare_result)); $delta_img = imagecreatefromstring(base64_decode($compare_result)); $img_width = imagesx($base_img); $img_height = imagesy($base_img); $img_changed = false; for ($x = 0; $x < $img_width; $x++) { for ($y = 0; $y < $img_height; $y++) { $base_image_color = pts_image::rgb_gd_color_at($base_img, $x, $y); $compare_image_color = pts_image::rgb_gd_color_at($compare_img, $x, $y); if ($base_image_color == $compare_image_color || pts_image::rgb_int_diff($base_image_color, $compare_image_color) < 9) { if ($cords = pts_image::color_pixel_delta($base_img, $compare_img, $x, $y)) { $pixel_rgb = pts_image::rgb_gd_color_at($delta_img, $cords[0], $cords[1]); $color_invert = imagecolorresolve($delta_img, 255 - $pixel_rgb[0], 255 - $pixel_rgb[1], 255 - $pixel_rgb[2]); imagesetpixel($delta_img, $x, $y, $color_invert); $img_changed = true; } } } } if ($img_changed) { imagepng($delta_img, PTS_SAVE_RESULTS_PATH . $extract_to . '/scratch.png'); $result_value = base64_encode(file_get_contents(PTS_SAVE_RESULTS_PATH . $extract_to . '/scratch.png', FILE_BINARY)); pts_file_io::unlink(PTS_SAVE_RESULTS_PATH . $extract_to . '/scratch.png'); $result_file_writer->add_result_from_result_object_with_value_string($result_object, $result_value); } } pts_client::save_result_file($result_file_writer, $extract_to); pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $extract_to . '/composite.xml'); }
Copyright (C) 2015, Phoronix Media Copyright (C) 2015, Michael Larabel This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ $result_share_opt = phoromatic_server::read_setting('force_result_sharing') ? '1 = 1' : 'AccountID IN (SELECT AccountID FROM phoromatic_account_settings WHERE LetOtherGroupsViewResults = "1")'; $stmt = phoromatic_server::$db->prepare('SELECT AccountID, UploadID FROM phoromatic_results WHERE (' . $result_share_opt . ' OR AccountID = :account_id) AND PPRID = :pprid LIMIT 1'); $stmt->bindValue(':account_id', ACCOUNT_ID); $stmt->bindValue(':pprid', $ID); $result = $stmt->execute(); if ($result && ($row = $result->fetchArray())) { $composite_xml = phoromatic_server::phoromatic_account_result_path($row['AccountID'], $row['UploadID']) . 'composite.xml'; if ($composite_xml) { $composite_xml = pts_merge::merge_test_results_array(array($composite_xml)); $json['phoromatic']['result']['composite_xml'] = base64_encode($composite_xml); //$json['phoromatic']['result']['system_logs_available'] = is_file($sys_log_file) ? sha1_file($sys_log_file) : false; echo json_encode($json); return; } }
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_file = 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_file, 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_file) < 21) { $show_only_latest_systems = null; } $writer = new pts_result_file_writer(null); $attributes = array('new_result_file_title' => phoromatic_schedule_id_to_name($row['ScheduleID'])); pts_merge::merge_test_results_process($writer, $result_file, $attributes); $result_file = new pts_result_file($writer->get_xml()); $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 (!empty($show_only_latest_systems) && false) { $main .= '<h2>Latest System States:</h2>'; $writer2 = new pts_result_file_writer(null); $a = array(); pts_merge::merge_test_results_process($writer2, $show_only_latest_systems, $a); $result_file2 = new pts_result_file($writer2->get_xml()); $table = new pts_ResultFileSystemsTable($result_file2); } else { 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(); }