chore: add todolist for benchmark case

This commit is contained in:
harttle
2020-03-10 01:10:13 +08:00
parent 6de933897e
commit 3aa47f6c85
12 changed files with 486 additions and 121 deletions
+28
View File
@@ -0,0 +1,28 @@
const Benchmark = require('benchmark')
const { Liquid } = require('..')
const liquid = new Liquid()
function output () {
console.log('--- output ---')
return new Promise(resolve => {
new Benchmark.Suite('output')
.add('literal', test('{{false}}{{"foo"}}{{32.322}}'))
.add('truncate', test('{{"foobar" | truncate: 3}}'))
.add('date', test('{{"now" | date: "%d%Y%m"}}'))
.add('escape', test('{{"1<2" | escape}}'))
.add('default', test('{{"" | default: 3}}'))
.on('cycle', (event) => console.log(String(event.target)))
.on('complete', resolve)
.run({ 'async': true })
})
}
function test (str) {
return {
defer: true,
fn: d => liquid.parseAndRender(str).then(x => d.resolve(x))
}
}
module.exports = { output }