aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/blob.mjs
blob: 68ebc1ce4d25912bf89e0d6e511c6ad2667ccc96 (plain) (blame)
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
import { bench, run } from "../node_modules/mitata/src/cli.mjs";

bench("new Blob(['hello world'])", function () {
  return new Blob(["hello world"]);
});

var small = new Blob([JSON.stringify("hello world ")]);
bench("blob.text(small string)", function () {
  return small.text();
});

bench("blob.arrayBuffer(small string)", function () {
  return small.arrayBuffer();
});

// if (Blob.prototype.json) {
//   bench("blob.json(small string)", function () {
//     return small.json();
//   });
// }

bench("blob.slice()", function () {
  return small.slice();
});

if ((await small.text()) !== JSON.stringify("hello world ")) {
  throw new Error("blob.text() failed");
}

await run();