Skip to content

Commit 5e866b7

Browse files
committed
bench: make collecting data into csv easier
1 parent 8b8f2ff commit 5e866b7

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

bench/bench-dom-bindings.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,21 @@ whichMap.addEventListener("input", e => {
5757
multiplyBy.addEventListener("input", e => {
5858
e.preventDefault();
5959
updateTestSourceMap();
60-
})
60+
});
61+
62+
var implAndBrowser = "<unknown>";
63+
64+
const implAndBrowserInput = document.getElementById("impl-and-browser");
65+
const updateImplAndBrowser = () => {
66+
implAndBrowser = implAndBrowserInput.value;
67+
};
68+
implAndBrowserInput.addEventListener("input", updateImplAndBrowser);
69+
updateImplAndBrowser();
70+
6171

6272
// Run a benchmark when the given button is clicked and display results in the
6373
// given element.
64-
function benchOnClick(button, results, bencher) {
74+
function benchOnClick(button, results, benchName, bencher) {
6575
button.addEventListener("click", async function (e) {
6676
e.preventDefault();
6777

@@ -74,6 +84,11 @@ function benchOnClick(button, results, bencher) {
7484

7585
buttons.forEach(b => b.removeAttribute("disabled"));
7686

87+
const csv = stats
88+
.xs
89+
.map(x => `${testSourceMap.mappings.length},"${benchName}",${x}`)
90+
.join("\n");
91+
7792
results.innerHTML = `
7893
<table>
7994
<thead>
@@ -93,7 +108,7 @@ function benchOnClick(button, results, bencher) {
93108
</tr>
94109
</tbody>
95110
</table>
96-
<pre style="overflow:hidden">${stats.xs}</pre>
111+
<pre style="overflow:scroll;max-height:100px; max-width:500px;outline:1px solid black">${csv}</pre>
97112
`;
98113
}, false);
99114
}
@@ -109,5 +124,5 @@ for (let bench of Object.keys(benchmarks)) {
109124
const results = document.createElement("div");
110125
document.body.appendChild(results);
111126

112-
benchOnClick(button, results, benchmarks[bench]);
127+
benchOnClick(button, results, bench, benchmarks[bench]);
113128
}

bench/bench.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ <h1>Benchmark <code>mozilla/source-map</code></h1>
5858
<input id="multiply-size-by" type="number", value="1", min="1", max="10", step="1"/>
5959
</label>
6060
</p>
61+
<p>
62+
<label>
63+
Implementation and Browser:
64+
<input id="impl-and-browser" value="<unknown>" />
65+
</label>
66+
</p>
6167
</form>
6268

6369
<script src="self-source-map.js"></script>

bench/bench.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ var benchmarks = {
8181
);
8282
},
8383

84-
"set first breakpoint (parse + query-by-original-location)": () => {
84+
"set.first.breakpoint": () => {
8585
let testMapping;
8686
return benchmark(
8787
async function () {
@@ -100,7 +100,7 @@ var benchmarks = {
100100
);
101101
},
102102

103-
"first pause at exception (parse + query-by-generated-location)": () => {
103+
"first.pause.at.exception": () => {
104104
let testMapping;
105105
return benchmark(
106106
async function () {
@@ -119,7 +119,7 @@ var benchmarks = {
119119
);
120120
},
121121

122-
"subsequent setting breakpoints (already parsed; query-by-original-location)": () => {
122+
"subsequent.setting.breakpoints": () => {
123123
let testMapping;
124124
let smc;
125125
return benchmark(
@@ -139,7 +139,7 @@ var benchmarks = {
139139
)
140140
},
141141

142-
"subsequent pauses at exception (already parsed; query-by-generated-location)": () => {
142+
"subsequent.pausing.at.exceptions": () => {
143143
let testMapping;
144144
let smc;
145145
return benchmark(
@@ -159,7 +159,7 @@ var benchmarks = {
159159
);
160160
},
161161

162-
"parse + iterating over all mappings": () => {
162+
"parse.and.iterate": () => {
163163
return benchmark(
164164
noop,
165165
async function () {
@@ -181,7 +181,7 @@ var benchmarks = {
181181
);
182182
},
183183

184-
"already parsed; iterating over all mappings": () => {
184+
"iterate.already.parsed": () => {
185185
let smc;
186186
return benchmark(
187187
async function () {

0 commit comments

Comments
 (0)