1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Browser tests</title>
</head>
<body>
<script>
const data1 = new Uint16Array([
0x1122, 0x3344, 0x5566, 0x7788, 0x1122, 0x3344, 0x5566, 0x7788,
0x1122, 0x3344, 0x5566, 0x7788, 0x1122, 0x3344, 0x5566, 0x7788
]);
// stress test (2**24 conversions - 2048x2048 pixels in RGBA)
const data2 = new Uint16Array(Array(2**24).fill(0xff00));
// umd test
setTimeout(() => {
console.log('umd loaded:', !!dummy.convert16BitTo8BitData);
console.log(dummy.convert16BitTo8BitData(data1));
const start_umd = Date.now();
dummy.convert16BitTo8BitData(data2);
console.log('duration of 2**24 channel values:', Date.now() - start_umd);
}, 100);
</script>
<script type="module">
// esm test
import {convert16BitTo8BitData} from '/dist/esm.js';
setTimeout(() => {
console.log('esm loaded:', !!convert16BitTo8BitData);
console.log(convert16BitTo8BitData(data1));
const start_esm = Date.now();
convert16BitTo8BitData(data2);
console.log('duration of 2**24 channel values:', Date.now() - start_esm);
}, 200);
</script>
<script src="/dist/umd.js"></script>
</body>
</html>
|