Skip to content

Commit a4b8fd0

Browse files
committed
docs(i18n): translate content/ja/docs/languages/js/benchmarks.md into ja
1 parent 86bb29b commit a4b8fd0

File tree

1 file changed

+188
-0
lines changed

1 file changed

+188
-0
lines changed
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
---
2+
title: ベンチマーク
3+
weight: 101
4+
default_lang_commit: 6f3712c5cda4ea79f75fb410521880396ca30c91
5+
cSpell:ignore: Elems rrggbbaa
6+
---
7+
8+
<link rel="stylesheet" href="/css/benchmarks.css">
9+
10+
OpenTelemetry JavaScript SDKは、[opentelemetry-js](https://github.com/open-telemetry/opentelemetry-js/)リポジトリへの各コミットでベンチマークテストを実行します。
11+
これらのテストの目的は、重要な操作のパフォーマンス傾向を時間の経過とともに追跡することです。
12+
これらのテストは、エンドツーエンドのパフォーマンステストの代替ではありません。
13+
14+
<div class="container">
15+
<main id="main"></main>
16+
</div>
17+
18+
<footer>
19+
<button id="dl-button">JSONとしてデータをダウンロード</button>
20+
<div class="spacer"></div>
21+
<div class="small"><a rel="noopener"
22+
href="https://github.com/marketplace/actions/continuous-benchmark">github-action-benchmark</a>によって動作</div>
23+
</footer>
24+
25+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.min.js"></script>
26+
<script src="https://open-telemetry.github.io/opentelemetry-js/benchmarks/data.js"></script>
27+
<script id="main-script">
28+
'use strict';
29+
(function() {
30+
const COLORS = [
31+
"#48aaf9",
32+
"#8a3ef2",
33+
"#78eeda",
34+
"#d78000",
35+
"#1248b3",
36+
"#97dbfc",
37+
"#006174",
38+
"#00b6b6",
39+
"#854200",
40+
"#f3c8ad",
41+
"#410472",
42+
];
43+
44+
function init() {
45+
function collectBenchesPerTestCase(entries) {
46+
const map = new Map();
47+
for (const entry of entries) {
48+
const {commit, date, tool, benches} = entry;
49+
for (const bench of benches) {
50+
const result = { commit, date, tool, bench };
51+
const arr = map.get(bench.name);
52+
if (arr === undefined) {
53+
map.set(bench.name, [result]);
54+
} else {
55+
arr.push(result);
56+
}
57+
}
58+
}
59+
return map;
60+
}
61+
62+
const data = window.BENCHMARK_DATA;
63+
64+
// Render footer
65+
document.getElementById('dl-button').onclick = () => {
66+
const dataUrl = 'data:,' + JSON.stringify(data, null, 2);
67+
const a = document.createElement('a');
68+
a.href = dataUrl;
69+
a.download = 'benchmark_data.json';
70+
a.click();
71+
};
72+
73+
// Prepare data points for charts
74+
return Object.keys(data.entries).map(name => ({
75+
name,
76+
dataSet: collectBenchesPerTestCase(data.entries[name]),
77+
}));
78+
}
79+
80+
function renderAllChars(dataSets) {
81+
82+
function renderGraph(parent, name, dataset) {
83+
const chartTitle = document.createElement('h3');
84+
chartTitle.textContent = name;
85+
parent.append(chartTitle);
86+
87+
const canvas = document.createElement('canvas');
88+
canvas.className = 'benchmark-chart';
89+
parent.appendChild(canvas);
90+
91+
const color = COLORS[0];
92+
const data = {
93+
labels: dataset.map(d => d.commit.id.slice(0, 7)),
94+
datasets: [
95+
{
96+
label: name,
97+
data: dataset.map(d => d.bench.value),
98+
borderColor: color,
99+
backgroundColor: color + '60', // Add alpha for #rrggbbaa,
100+
fill: false
101+
}
102+
],
103+
};
104+
const options = {
105+
scales: {
106+
xAxes: [
107+
{
108+
scaleLabel: {
109+
display: true,
110+
labelString: 'commit',
111+
},
112+
}
113+
],
114+
yAxes: [
115+
{
116+
scaleLabel: {
117+
display: true,
118+
labelString: dataset.length > 0 ? dataset[0].bench.unit : '',
119+
},
120+
ticks: {
121+
beginAtZero: true,
122+
}
123+
}
124+
],
125+
},
126+
tooltips: {
127+
callbacks: {
128+
afterTitle: items => {
129+
const {index} = items[0];
130+
const data = dataset[index];
131+
return '\n' + data.commit.message + '\n\n' + data.commit.timestamp + ' committed by @' + data.commit.committer.username + '\n';
132+
},
133+
label: item => {
134+
let label = item.value;
135+
const { range, unit } = dataset[item.index].bench;
136+
label += ' ' + unit;
137+
if (range) {
138+
label += ' (' + range + ')';
139+
}
140+
return label;
141+
},
142+
afterLabel: item => {
143+
const { extra } = dataset[item.index].bench;
144+
return extra ? '\n' + extra : '';
145+
}
146+
}
147+
},
148+
onClick: (_mouseEvent, activeElems) => {
149+
if (activeElems.length === 0) {
150+
return;
151+
}
152+
// XXX: Undocumented. How can we know the index?
153+
const index = activeElems[0]._index;
154+
const url = dataset[index].commit.url;
155+
window.open(url, '_blank');
156+
},
157+
};
158+
159+
new Chart(canvas, {
160+
type: 'line',
161+
data,
162+
options,
163+
});
164+
}
165+
166+
function renderBenchSet(name, benchSet, main) {
167+
const setElem = document.createElement('div');
168+
setElem.className = 'benchmark-set';
169+
main.appendChild(setElem);
170+
171+
const graphsElem = document.createElement('div');
172+
graphsElem.className = 'benchmark-graphs';
173+
setElem.appendChild(graphsElem);
174+
175+
for (const [benchName, benches] of benchSet.entries()) {
176+
renderGraph(graphsElem, benchName, benches)
177+
}
178+
}
179+
180+
const main = document.getElementById('main');
181+
for (const {name, dataSet} of dataSets) {
182+
renderBenchSet(name, dataSet, main);
183+
}
184+
}
185+
186+
renderAllChars(init()); // Start
187+
})();
188+
</script>

0 commit comments

Comments
 (0)