Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 'use strict'
  2. var max = 1000000
  3. var fastqueue = require('./')(worker, 1)
  4. var async = require('async')
  5. var neo = require('neo-async')
  6. var asyncqueue = async.queue(worker, 1)
  7. var neoqueue = neo.queue(worker, 1)
  8. function bench (func, done) {
  9. var key = max + '*' + func.name
  10. var count = -1
  11. console.time(key)
  12. end()
  13. function end () {
  14. if (++count < max) {
  15. func(end)
  16. } else {
  17. console.timeEnd(key)
  18. if (done) {
  19. done()
  20. }
  21. }
  22. }
  23. }
  24. function benchFastQ (done) {
  25. fastqueue.push(42, done)
  26. }
  27. function benchAsyncQueue (done) {
  28. asyncqueue.push(42, done)
  29. }
  30. function benchNeoQueue (done) {
  31. neoqueue.push(42, done)
  32. }
  33. function worker (arg, cb) {
  34. setImmediate(cb)
  35. }
  36. function benchSetImmediate (cb) {
  37. worker(42, cb)
  38. }
  39. function runBench (done) {
  40. async.eachSeries([
  41. benchSetImmediate,
  42. benchFastQ,
  43. benchNeoQueue,
  44. benchAsyncQueue
  45. ], bench, done)
  46. }
  47. runBench(runBench)