pipeline_test.js 528 B

12345678910111213141516171819202122232425262728
  1. var suite = new Benchmark.Suite,
  2. elements = [],
  3. fn1 = function (t) { return t },
  4. fn2 = function (t) { return t },
  5. pipeline = new lunr.Pipeline
  6. for (var i = 0; i < 10000; i++) {
  7. elements[i] = Math.random() * 100
  8. };
  9. pipeline.add(fn1, fn2)
  10. suite.add('pipeline#run', function () {
  11. pipeline.run(elements)
  12. })
  13. suite.on('cycle', function (e) {
  14. console.log(e.target.name)
  15. })
  16. suite.on('complete', function (e) {
  17. suite.forEach(function (s) {
  18. console.log(s.name, s.count)
  19. })
  20. })
  21. suite.run({async: true})