adoptium / adoptium/aqa-test-tools

Simplify the logic in PerfCompare.js

Open
#215 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Jupyter Notebook
Stars
33
Forks
97
Avg merge
7h 9m
Merged PRs (30d)
5

Description

In [PerfCompare.js](https://github.com/AdoptOpenJDK/openjdk-test-tools/blob/master/test-result-summary-client/src/PerfCompare/PerfCompare.jsx), we are using `undefined`, `null`, `""` to represent different meanings. I think we should simplify the logic.

- [ ] `higherbetter ` should have only two state. i.e., true or false. There is no need to have a third state `undefined`. The default value for `higherbetter` in [BenchmarkMetric.js](https://github.com/AdoptOpenJDK/openjdk-test-tools/blob/master/TestResultSummaryService/parsers/BenchmarkMetric.js) should be true. It only needs to set explicitly if it is false.

- [ ] Remove sepcific checks for `undefined`, `null`, `""`. Update code as the following:
```
if (resBenchmarkRunsJson === undefined || (Object.keys(resBenchmarkRunsJson).length === 0 && resBenchmarkRunsJson.constructor === Object) ||
resBenchmarkRunsJson.baselineCSV === undefined || resBenchmarkRunsJson.testCSV === undefined) {
```
to
```
if (!resBenchmarkRunsJson || !resBenchmarkRunsJson.baselineCSV || !resBenchmarkRunsJson.testCSV)
```
Please check the code and update similar checks.

Contributor guide

Open the contributing guide

Research direction

Start by reading test-result-summary-client/src/PerfCompare/PerfCompare.jsx and TestResultSummaryService/parsers/BenchmarkMetric.js, then search these areas for the undefined, null, and empty-string checks. Done means higherbetter defaults to true and uses only true or false, while equivalent checks are simplified consistently without changing the intended behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, frontend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.