Skip to content
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
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Make the chromedriver package download the driver matching the installed
# Chrome instead of the version pinned in the lockfile.
detect_chromedriver_version=true
6 changes: 6 additions & 0 deletions apps/table-app/_shared/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function _random(max) {
* @property {() => void} runLots
* @property {() => void} clear
* @property {() => void} swapRows
* @property {(n: number) => void} displace
*/

/** @typedef {{id: number; label: string}} Data */
Expand Down Expand Up @@ -146,4 +147,9 @@ export class Store {
this.data[998] = a;
}
}
/** Move the first `n` rows to the end of the list.
* @param {number} n */
displace(n) {
this.data = this.data.slice(n).concat(this.data.slice(0, n));
}
}
7 changes: 7 additions & 0 deletions apps/table-app/preact-class/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ export class Main extends Component {
this.state.store.swapRows();
this.setState({ store: this.state.store });
}
/** @param {number} n */
displace(n) {
this.state.store.displace(n);
this.setState({ store: this.state.store });
}
render() {
let rows = this.state.store.data.map((d, i) => {
return createElement(Row, {
Expand Down Expand Up @@ -143,6 +148,7 @@ export function render(rootDom, props) {
runLots: app.runLots.bind(app),
clear: app.clear.bind(app),
swapRows: app.swapRows.bind(app),
displace: app.displace.bind(app),
};
}

Expand All @@ -163,5 +169,6 @@ export function hydrate(rootDom, props) {
runLots: app.runLots.bind(app),
clear: app.clear.bind(app),
swapRows: app.swapRows.bind(app),
displace: app.displace.bind(app),
};
}
5 changes: 5 additions & 0 deletions apps/table-app/preact-hooks/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ function Main({ store: initialStore }) {
store.swapRows();
forceUpdate();
},
/** @param {number} n */
displace(n) {
store.displace(n);
forceUpdate();
},
};
}, []);

Expand Down
5 changes: 5 additions & 0 deletions apps/table-app/preact/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ function createTableApp(store, rootDom) {
store.swapRows();
rerender();
},
/** @param {number} n */
displace(n) {
store.displace(n);
rerender();
},
};

rerender = () =>
Expand Down
69 changes: 69 additions & 0 deletions apps/table-app/reorder1k.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>reorder rows</title>
<meta
name="description"
content="moving the first 3 of 1,000 rows to the end (3 warmup runs)"
/>
<style>
.preloadicon {
display: none;
}
.glyphicon-remove:before {
content: "⨯";
}
</style>
</head>
<body>
<div id="main"></div>
<script type="module">
import {
measureName,
measureMemory,
afterFrameAsync,
testElementText,
markRunStart,
markRunEnd,
} from "../utils.js";
import { render } from "@impl";

const app = render(document.getElementById("main"));
const firstIdSel = "tr:first-child > td:first-child";

async function init() {
app.run();

await afterFrameAsync();
testElementText(firstIdSel, "1");

for (let i = 0; i < 3; i++) {
markRunStart(`warmup-${i}`);
app.displace(3);
await markRunEnd(`warmup-${i}`);

await afterFrameAsync();
testElementText(firstIdSel, `${3 * (i + 1) + 1}`);
}
}

async function run() {
markRunStart("final");
performance.mark("start");
app.displace(3);

await markRunEnd("final");
await afterFrameAsync();
testElementText(firstIdSel, "13");
performance.mark("stop");
performance.measure(measureName, "start", "stop");

measureMemory();
}

init().then(run);
</script>
</body>
</html>
Loading