Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revised website codes to show all middleware results in one graph #20

Merged
merged 2 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes" />
<style>
html {
font-family: BlinkMacSystemFont,-apple-system,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Fira Sans","Droid Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
-webkit-font-smoothing: antialiased;
background-color: #fff;
font-size: 16px;
}
body {
color: #4a4a4a;
margin: 8px;
font-size: 1em;
font-weight: 400;
}
header {
margin-bottom: 8px;
display: flex;
flex-direction: column;
}
main {
width: 100%;
display: flex;
flex-direction: column;
}
a {
color: #3273dc;
cursor: pointer;
text-decoration: none;
}
a:hover {
color: #000;
}
button {
color: #fff;
background-color: #3298dc;
border-color: transparent;
cursor: pointer;
text-align: center;
}
button:hover {
background-color: #2793da;
flex: none;
}
.spacer {
flex: auto;
}
.small {
font-size: 0.75rem;
}
footer {
margin-top: 16px;
display: flex;
align-items: center;
}
.header-label {
margin-right: 4px;
}
.benchmark-set {
margin: 8px 0;
width: 100%;
display: flex;
flex-direction: column;
}
.benchmark-title {
font-size: 3rem;
font-weight: 600;
word-break: break-word;
text-align: center;
}
.benchmark-graphs {
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
width: 100%;
}
.benchmark-chart {
max-width: 1000px;
}
</style>
<title>Benchmarks</title>
</head>

<body>
<header id="header">
<div class="header-item">
<strong class="header-label">Last Update:</strong>
<span id="last-update"></span>
</div>
<div class="header-item">
<strong class="header-label">Repository:</strong>
<a id="repository-link" rel="noopener" link="https://github.com/CihatAltiparmak/moveit_middleware_benchmark">moveit_middleware_benchmark</a>
</div>
</header>
<main id="main"></main>
<footer>
<button id="dl-button">Download data as JSON</button>
<div class="spacer"></div>
<div class="small">Powered by <a rel="noopener" href="https://github.com/marketplace/actions/continuous-benchmark">github-action-benchmark</a></div>
</footer>

<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.2/dist/Chart.min.js"></script>
<script type="module" src="index.js"></script>
</body>
</html>
156 changes: 156 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import * as fastrtps_benchmark_data from './rmw_fastrtps/common.js';
import * as cyclonedds_benchmark_data from './rmw_cyclonedds/common.js';
// @TODO CihatAltiparmak when enable, add below line for zenoh bechmark dataset
// import * as zenoh_benchmark_data from './rmw_zenoh/common.js';

'use strict';

const middlewareColors = {
rmw_zenoh: '#dea584',
rmw_cyclonedds: '#00add8',
rmw_fastrtps: '#f34b7d',

};

function reformat_dataset(middleware_data_list) {
const map = new Map();

for (const [middleware_name, middleware] of middleware_data_list) {
for (const scenario of Object.keys(middleware.entries)) {
if (!map.has(scenario)) {
map.set(scenario, new Map());
}
map.get(scenario).set(middleware_name, new Array());
}
}

for (const scenario of map.keys()) {

for (const middleware_name of map.get(scenario).keys()) {

for (const commit of middleware_data_list.get(middleware_name).entries[scenario]) {

map.get(scenario).get(middleware_name).push({
id: commit.commit.id,
'value': commit.benches[0].value,
'unit': commit.benches[0].unit
});
}
}
}


return map;
}

function init() {

const fastrtps_data = fastrtps_benchmark_data.BENCHMARK_DATA;
const cyclonedds_data = cyclonedds_benchmark_data.BENCHMARK_DATA;
// @TODO CihatAltiparmak when enable, add below line for zenoh bechmark dataset
// const data = zenoh_benchmark_data.BENCHMARK_DATA;


const middleware_datasets = reformat_dataset(
new Map([
["rmw_fastrtps", fastrtps_data],
["rmw_cyclonedds", cyclonedds_data]
// ["rmw_zenoh", data]]
]));

return middleware_datasets;
}

function renderGraph(parent, name, dataset, label) {
const canvas = document.createElement('canvas');
canvas.className = 'benchmark-chart';
parent.appendChild(canvas);

const data = {
labels: label,
datasets: dataset,
};
const options = {
scales: {
xAxes: [{
scaleLabel: {
display: true,
labelString: 'commit',
},
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'ns/iter',
},
ticks: {
beginAtZero: true,
}
}],
},
};

new Chart(canvas, {
type: 'line',
data,
options,
});
}


function create_plot_datasets(scenario_dataset) {

var most_commit_number = 0;
var longest_commit_array = new Array();

for (const [middleware_name, commit_array] of scenario_dataset.entries()) {
if (commit_array.length > most_commit_number) {
most_commit_number = commit_array.length;
longest_commit_array = commit_array;
}
}

const plot_dataset = new Array();
for (const [middleware_name, commit_array] of scenario_dataset.entries()) {
plot_dataset.push({
id: commit_array.map(commit => commit.id),
label: middleware_name,
data: commit_array.map(commit => commit.value),
borderColor: middlewareColors[middleware_name],
backgroundColor: middlewareColors[middleware_name] + '60'
})
}

return {
"plot_dataset": plot_dataset,
"longest_commit_array": longest_commit_array.map(commit => commit.id.slice(0, 7))
};
}

function renderBenchmark(scenario_name, scenarioDataset, main) {
const setElem = document.createElement('div');
setElem.className = 'benchmark-set';
main.appendChild(setElem);

const nameElem = document.createElement('h1');
nameElem.className = 'benchmark-title';
nameElem.textContent = scenario_name;
setElem.appendChild(nameElem);

const graphsElem = document.createElement('div');
graphsElem.className = 'benchmark-graphs';
setElem.appendChild(graphsElem);

const plot_dataset_info = create_plot_datasets(scenarioDataset);
renderGraph(graphsElem, scenario_name, plot_dataset_info["plot_dataset"], plot_dataset_info["longest_commit_array"]);
}

function renderAllChars(dataSet) {

const main = document.getElementById('main');
for (const scenario_name of dataSet.keys()) {
renderBenchmark(scenario_name, dataSet.get(scenario_name), main);
}
}

renderAllChars(init()); // Start
2 changes: 2 additions & 0 deletions rmw_cyclonedds/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import * as my_data from './data.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit confused where the data is coming from. Aren't these supposed to be just json files?

Copy link
Member Author

@CihatAltiparmak CihatAltiparmak Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data will come from github-action-benchmark tool which will be triggered by our other CI's. It's absent due to the fact that our other CI's didn't pass updates here. For example: https://github.com/DarkusAlphaHydranoid/moveit_middleware_benchmark_experimental/tree/gh-pages/rmw_fastrtps

export var BENCHMARK_DATA = window.BENCHMARK_DATA;
2 changes: 2 additions & 0 deletions rmw_fastrtps/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import * as my_data from './data.js';
export var BENCHMARK_DATA = window.BENCHMARK_DATA;
2 changes: 2 additions & 0 deletions rmw_zenoh/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import * as my_data from './data.js';
export var BENCHMARK_DATA = window.BENCHMARK_DATA;