Skip to content

Commit

Permalink
Don't clear results buffer between loops
Browse files Browse the repository at this point in the history
When tests or suites are looped with TOTAL_LOOP_COUNT or TOTAL_LOOP_TIME, each loop would produce an independent result entry with identical identifiers (descriptions).
However, the results viewer and exporters silently ignore any results with duplicate identifiers.
This change combines the results from all loops into a single result entry to avoid the issue.

Note: This change may cause data loss in existing result files if they have multiple results with the same identifiers.
But since those multiple results were never "visible" to users in the first place, it's not a practical issue.

Fixes #735
  • Loading branch information
kotarou3 committed Jul 11, 2023
1 parent d9bcf66 commit d60a577
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 0 additions & 2 deletions pts-core/objects/client/pts_test_execution.php
Expand Up @@ -68,8 +68,6 @@ public static function run_test(&$test_run_manager, &$test_run_request)
return false;
}

$test_run_request->active = new pts_test_result_buffer_active();
$test_run_request->generated_result_buffers = array();
$execute_binary = $test_run_request->test_profile->get_test_executable();
$times_to_run = $test_run_request->test_profile->get_times_to_run();
$ignore_runs = $test_run_request->test_profile->get_runs_to_ignore();
Expand Down
3 changes: 3 additions & 0 deletions pts-core/objects/pts_test_result.php
Expand Up @@ -49,6 +49,9 @@ class pts_test_result
public function __construct($test_profile)
{
$this->test_profile = clone $test_profile;

$this->active = new pts_test_result_buffer_active();
$this->generated_result_buffers = array();
$this->test_run_times = array();
}
public function get_estimated_run_time()
Expand Down
19 changes: 8 additions & 11 deletions pts-core/objects/pts_test_result_buffer.php
Expand Up @@ -51,26 +51,23 @@ public function __construct($buffer_items = array())
}
public function add_buffer_item($buffer_item)
{
if(isset($this->buffer_by_identifier[$buffer_item->get_result_identifier()]) && $this->buffer_items[$this->buffer_by_identifier[$buffer_item->get_result_identifier()]]->get_result_value() == '')
if(isset($this->buffer_by_identifier[$buffer_item->get_result_identifier()]))
{
// Overwrite the buffer item if there is a match but empty (incomplete) result
// Overwrite the buffer item if there is an existing match
$this->remove($buffer_item->get_result_identifier());
}

if(!$this->buffer_contained($buffer_item))
{
$this->buffer_items[] = $buffer_item;
$this->buffer_by_identifier[$buffer_item->get_result_identifier()] = (count($this->buffer_items) - 1);
$this->buffer_contains[$buffer_item->get_result_identifier() . $buffer_item->get_result_value()] = 1;
$this->check_buffer_item_for_min_max($buffer_item);
}
$this->buffer_items[] = $buffer_item;
$this->buffer_by_identifier[$buffer_item->get_result_identifier()] = (count($this->buffer_items) - 1);
$this->buffer_contains[$buffer_item->get_result_identifier() . $buffer_item->get_result_value()] = 1;
$this->check_buffer_item_for_min_max($buffer_item);
}
public function add_test_result($identifier, $value, $raw_value = null, $json = null, $min_value = null, $max_value = null)
{
$buffer_item = new pts_test_result_buffer_item($identifier, $value, $raw_value, $json, $min_value, $max_value);
if(isset($this->buffer_by_identifier[$buffer_item->get_result_identifier()]) && $this->buffer_items[$this->buffer_by_identifier[$buffer_item->get_result_identifier()]]->get_result_value() == '')
if(isset($this->buffer_by_identifier[$buffer_item->get_result_identifier()]))
{
// Overwrite the buffer item if there is a match but empty (incomplete) result
// Overwrite the buffer item if there is an existing match
$this->remove($buffer_item->get_result_identifier());
}

Expand Down
1 change: 0 additions & 1 deletion pts-core/objects/pts_test_result_parser.php
Expand Up @@ -381,7 +381,6 @@ public static function generate_extra_data(&$test_result, &$test_log_file = null
$tp->set_display_format('LINE_GRAPH');
$tp->set_identifier(null);
$extra_result = new pts_test_result($tp);
$extra_result->active = new pts_test_result_buffer_active();
$extra_result->set_used_arguments_description($test_result->get_arguments_description() . ' - Total Frame Time');
$extra_result->set_used_arguments($test_result->get_arguments() . ' - ' . $extra_result->get_arguments_description()); // this formatting is weird but to preserve pre-PTS7 comparsions of extra results
$extra_result->active->set_result(implode(',', $frame_all_times));
Expand Down

0 comments on commit d60a577

Please sign in to comment.