1
|
const Benchmark = require('benchmark');
|
2
|
const mime = require('..');
|
3
|
const mimeLite = require('../lite');
|
4
|
|
5
|
const suite = new Benchmark.Suite();
|
6
|
|
7
|
const extensions = Object.keys(mime._types);
|
8
|
let idx = 0;
|
9
|
|
10
|
suite
|
11
|
.add('mime.getType',
|
12
|
function() {
|
13
|
mime.getType(extensions[idx++]);
|
14
|
if (idx >= extensions.length) idx = 0;
|
15
|
}
|
16
|
)
|
17
|
.add('mimeLite.getType',
|
18
|
function() {
|
19
|
mimeLite.getType(extensions[idx++]);
|
20
|
if (idx >= extensions.length) idx = 0;
|
21
|
}
|
22
|
)
|
23
|
.on('cycle', function(event) {
|
24
|
console.log(String(event.target));
|
25
|
})
|
26
|
.run();
|