-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbenchmark.js
40 lines (33 loc) · 1.18 KB
/
benchmark.js
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
'use strict';
const { PerformanceObserver, performance } = require('perf_hooks');
const Finder = require("./lib");
const EntryList = require("./lib/EntryList")
const {find} = require("./lib/MimeApps")
const {lookup} = require("./lib/MimeType");
const delay = (d)=> new Promise((r)=> setTimeout(r, d));
(async ()=>{
const obs = new PerformanceObserver((items) => {
console.log(items.getEntries()[0].duration);
performance.clearMarks();
});
obs.observe({ entryTypes: ['measure'] });
const f = new Finder();
await delay(300);
performance.mark("Finder");
await f.find("foo.mp4");
performance.mark("end_Finder");
performance.measure("Finder.find()", "Finder", "end_Finder");
performance.mark("find");
await find("foo.mp4");
performance.mark("end_find");
performance.measure("find() time", "find", "end_find");
performance.mark("lookup");
await lookup("video/mp4");
performance.mark("end_lookup");
performance.measure("lookup() time", "lookup", "end_lookup");
const el = new EntryList();
performance.mark("Entrylist");
await el.find("video/mp4");
performance.mark("end_Entrylist");
performance.measure("Entrylist() time", "Entrylist", "end_Entrylist");
})()