Skip to content

Commit

Permalink
Update Renaissance.jsx
Browse files Browse the repository at this point in the history
We made some style changes and made the code more clear.
  • Loading branch information
Sangyoon21 authored Jul 9, 2024
1 parent 341fbb5 commit 4d21641
Showing 1 changed file with 72 additions and 77 deletions.
149 changes: 72 additions & 77 deletions test-result-summary-client/src/Dashboard/Widgets/Graph/Renaissance.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import {
Tooltip,
} from 'react-jsx-highstock';
import DateRangePickers from '../DateRangePickers';
import { Radio, message } from 'antd';
import { Radio } from 'antd';
import BenchmarkMath from '../../../PerfCompare/lib/BenchmarkMath';
import { sort, std, mean, median, size } from 'mathjs';
import { sort, std, mean, size, median } from 'mathjs';
import { parseSha, getEpochTime } from './utils';
import { fetchData } from '../../../utils/Utils';

const map = {
'renaissance-jdk11': 'Test_openjdk11_j9_sanity.perf_x86-64_linux',
'renaissance-jdk8': 'Test_openjdk8_j9_sanity.perf_x86-64_linux',
'renaissance-jdk17': 'Test_openjdk17_hs_sanity.perf_arm_linux',
'renaissance-jdk21': 'Test_openjdk21_hs_sanity.perf_x86-64_linux',
'renaissance-jdk21': 'Test_openjdk21_hs_sanity.perf_x86-64_linux'
};

let servers = ['AdoptOpenJDK', 'CustomizedJenkins'];
Expand All @@ -44,22 +44,26 @@ export class RenaissanceSetting extends Component {
value={serverSelected}
defaultValue={'AdoptOpenJDK'}
>
{servers.map((server) => (
<Radio key={server} value={server}>
{server}
</Radio>
))}
{servers.map((server) => {
return (
<Radio key={server} value={server}>
{server}
</Radio>
);
})}
</Radio.Group>
<Radio.Group
onChange={this.onChange}
value={buildSelected}
values={buildSelected}
defaultValue={'renaissance-jdk11'}
>
{Object.keys(map).map((key) => (
<Radio key={key} value={key}>
{map[key]}
</Radio>
))}
{Object.keys(map).map((key) => {
return (
<Radio key={key} value={key}>
{map[key]}
</Radio>
);
})}
</Radio.Group>
</div>
);
Expand Down Expand Up @@ -95,34 +99,11 @@ export default class Renaissance extends Component {
async updateData() {
const { buildSelected, serverSelected } = this.props;
const buildName = encodeURIComponent(map[buildSelected]);
let results;
let buildInfoMap;

try {
results = await fetchData(
`/api/getBuildHistory?type=Perf&buildName=${buildName}&status=Done&limit=100&asc`
);
if (!Array.isArray(results)) {
throw new Error('Invalid response format');
}
console.log('Fetched results:', results);
} catch (error) {
console.error('Error fetching build history:', error);
message.error('Failed to fetch build history');
return;
}
let results = await fetchData(
`/api/getBuildHistory?type=Perf&buildName=${buildName}&status=Done&limit=100&asc`
);

try {
buildInfoMap = await fetchData(`/api/getDashboardBuildInfo`);
if (typeof buildInfoMap !== 'object') {
throw new Error('Invalid response format');
}
console.log('Fetched build info map:', buildInfoMap);
} catch (error) {
console.error('Error fetching dashboard build info:', error);
message.error('Failed to fetch dashboard build info');
return;
}
const buildInfoMap = await fetchData(`/api/getDashboardBuildInfo`);

if (serverSelected) {
if (serverSelected === 'AdoptOpenJDK') {
Expand Down Expand Up @@ -172,7 +153,7 @@ export default class Renaissance extends Component {

// combine results having the same JDK build date
results.forEach((t) => {
const jdkDate = t.jdkDate.trim(); // Trim the date to remove leading/trailing spaces
const jdkDate = t.jdkDate.trim();
if (t.buildResult !== 'SUCCESS' || !jdkDate) return;
resultsByJDKBuild[jdkDate] = resultsByJDKBuild[jdkDate] || [];
t.tests.forEach((test) => {
Expand All @@ -190,27 +171,37 @@ export default class Renaissance extends Component {
return;

test.testData.metrics.forEach((metric) => {
if (metric.name === 'akka-uct' && metric.value.length > 0) {
akkaUct = mean(metric.value);
if (metric.name === 'akka-uct') {
if (metric.value.length > 0) {
akkaUct = mean(metric.value);
}
}
if (metric.name === 'fj-kmeans' && metric.value.length > 0) {
fj = mean(metric.value);
if (metric.name === 'fj-kmeans') {
if (metric.value.length > 0) {
fj = mean(metric.value);
}
}
if (metric.name === 'future-genetic' && metric.value.length > 0) {
futureGenetic = mean(metric.value);
if (metric.name === 'future-genetic') {
if (metric.value.length > 0) {
futureGenetic = mean(metric.value);
}
}
if (metric.name === 'naive-bayes' && metric.value.length > 0) {
bayes = mean(metric.value);
if (metric.name === 'naive-bayes') {
if (metric.value.length > 0) {
bayes = mean(metric.value);
}
}
if (metric.name === 'scala-kmeans' && metric.value.length > 0) {
scala = mean(metric.value);
if (metric.name === 'scala-kmeans') {
if (metric.value.length > 0) {
scala = mean(metric.value);
}
}
});

if (!akkaUct && !fj && !futureGenetic && !bayes && !scala) {
return;
}

// TODO: current code only considers one interation. This needs to be updated
resultsByJDKBuild[jdkDate].push({
akkaUct,
fj,
Expand All @@ -236,7 +227,9 @@ export default class Renaissance extends Component {
const date = new Date(k).getTime();
let akkaUctGroup = resultsByJDKBuild[k]
.map((x) => x['akkaUct'])
.filter((el) => el != null);
.filter(function (el) {
return el != null;
});
if (akkaUctGroup.length > 0) {
akkaUctGtValues.push(mean(akkaUctGroup));
let myCi = 'N/A';
Expand All @@ -256,7 +249,9 @@ export default class Renaissance extends Component {

let fjGroup = resultsByJDKBuild[k]
.map((x) => x['fj'])
.filter((el) => el != null);
.filter(function (el) {
return el != null;
});
if (fjGroup.length > 0) {
fjGtValues.push(mean(fjGroup));
let myCi = 'N/A';
Expand All @@ -276,12 +271,15 @@ export default class Renaissance extends Component {

let futureGeneticGroup = resultsByJDKBuild[k]
.map((x) => x['futureGenetic'])
.filter((el) => el != null);
.filter(function (el) {
return el != null;
});
if (futureGeneticGroup.length > 0) {
futureGeneticGtValues.push(mean(futureGeneticGroup));
let myCi = 'N/A';
if (futureGeneticGroup.length > 1) {
myCi = BenchmarkMath.confidence_interval(futureGeneticGroup);
myCi =
BenchmarkMath.confidence_interval(futureGeneticGroup);
}
futureGeneticData.push([
date,
Expand All @@ -296,7 +294,9 @@ export default class Renaissance extends Component {

let bayesGroup = resultsByJDKBuild[k]
.map((x) => x['bayes'])
.filter((el) => el != null);
.filter(function (el) {
return el != null;
});
if (bayesGroup.length > 0) {
bayesGtValues.push(mean(bayesGroup));
let myCi = 'N/A';
Expand All @@ -316,12 +316,15 @@ export default class Renaissance extends Component {

let scalaGroup = resultsByJDKBuild[k]
.map((x) => x['scala'])
.filter((el) => el != null);
.filter(function (el) {
return el != null;
});
if (scalaGroup.length > 0) {
scalaGtValues.push(mean(scalaGroup));
let myCi = 'N/A';
if (scalaGroup.length > 1) {
myCi = BenchmarkMath.confidence_interval(scalaGroup);
myCi =
BenchmarkMath.confidence_interval(futureGeneticGroup);
}
scalaData.push([
date,
Expand Down Expand Up @@ -357,21 +360,15 @@ export default class Renaissance extends Component {
scalaMean,
scalaMedian,
};

const displaySeries = [];
for (let key in series) {
const sortedData = series[key].sort((a, b) => a[0] - b[0]);
displaySeries.push({
visible: key === 'fjData',
name: key,
data: sortedData,
data: series[key].sort((a, b) => a[0] - b[0]),
keys: ['x', 'y', 'additionalData', 'CI'],
events: {
click: (event) => handlePointClick(event),
},
});
}

this.setState({ displaySeries });
}

Expand All @@ -385,7 +382,9 @@ export default class Renaissance extends Component {
let prevPoint = i === 0 ? null : this.series.data[i - 1];
this.point.additionalData.forEach((xy) => {
const { testId, buildName, buildNum } = xy;
buildLinks += ` <a href="/output/test?id=${testId}">${buildName} #${buildNum}</a>`;
buildLinks =
buildLinks +
` <a href="/output/test?id=${testId}">${buildName} #${buildNum}</a>`;
});

let lengthThis = this.point.additionalData.length;
Expand Down Expand Up @@ -416,8 +415,6 @@ export default class Renaissance extends Component {

render() {
const { displaySeries } = this.state;
console.log('Rendering displaySeries:', displaySeries);

return (
<HighchartsStockChart>
<Chart zoomType="x" />
Expand Down Expand Up @@ -466,15 +463,13 @@ export default class Renaissance extends Component {
</RangeSelector>

<Navigator>
{displaySeries.map((s) => (
<Navigator.Series seriesId={s.name} key={s.name} />
))}
{displaySeries.map((s) => {
return (
<Navigator.Series seriesId={s.name} key={s.name} />
);
})}
</Navigator>
</HighchartsStockChart>
);
}
}

function handlePointClick(event) {
console.log('Point clicked:', event.point);
}

0 comments on commit 4d21641

Please sign in to comment.