make wasm smaller and update build/test system

This commit is contained in:
Toshit Chawda 2024-01-31 06:47:00 -08:00
parent c5cf95fcb1
commit 619a2a61c7
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
6 changed files with 49 additions and 22 deletions

View file

@ -8,13 +8,20 @@
const should_perf_test = (new URL(window.location.href)).searchParams.has("perf_test");
const should_ws_test = (new URL(window.location.href)).searchParams.has("ws_test");
const log = (str) => {
let el = document.createElement("div");
el.innerText = str;
document.getElementById("logs").appendChild(el);
console.warn(str);
}
let { EpoxyClient } = await epoxy();
const tconn0 = performance.now();
// args: websocket url, user agent, redirect limit
let epoxy_client = await new EpoxyClient("wss://localhost:4000", navigator.userAgent, 10);
const tconn1 = performance.now();
console.warn(`conn establish took ${tconn1 - tconn0} ms or ${(tconn1 - tconn0) / 1000} s`);
log(`conn establish took ${tconn1 - tconn0} ms or ${(tconn1 - tconn0) / 1000} s`);
if (should_feature_test) {
@ -47,20 +54,22 @@
const num_tests = 10;
let total_mux = 0;
for (const _ of Array(num_tests).keys()) {
for (const i of Array(num_tests).keys()) {
log(`running mux test ${i}`);
total_mux += await test_mux("https://httpbin.org/get");
}
total_mux = total_mux / num_tests;
let total_native = 0;
for (const _ of Array(num_tests).keys()) {
for (const i of Array(num_tests).keys()) {
log(`running native test ${i}`);
total_native += await test_native("https://httpbin.org/get");
}
total_native = total_native / num_tests;
console.warn(`avg mux (10) took ${total_mux} ms or ${total_mux / 1000} s`);
console.warn(`avg native (10) took ${total_native} ms or ${total_native / 1000} s`);
console.warn(`mux - native: ${total_mux - total_native} ms or ${(total_mux - total_native) / 1000} s`);
log(`avg mux (10) took ${total_mux} ms or ${total_mux / 1000} s`);
log(`avg native (10) took ${total_native} ms or ${total_native / 1000} s`);
log(`mux - native: ${total_mux - total_native} ms or ${(total_mux - total_native) / 1000} s`);
} else if (should_ws_test) {
let ws = await epoxy_client.connect_ws(
() => console.log("opened"),
@ -80,5 +89,5 @@
console.warn(resp, Object.fromEntries(resp.headers));
console.warn(await resp.text());
}
if (!should_ws_test) alert("you can open console now");
log("done");
})();