Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. async = require("async")
  2. Project = require('./app/js/models/Project').Project
  3. _ = require("lodash")
  4.  
  5. warmup = "55928319efc30e705817817e"
  6. smallproject = "561e86173cfc7400525834a6"
  7. twokproject = "5637a97beafc8c7b5bfc487a"
  8. fourkproject = "55ef4b39f5e895afbaf2085d"
  9. realmassive = "57b1ea8674e706f567b5afe8"
  10.  
  11. tenRuns = (key, callback)->
  12. findAndTime = (i, cb)->
  13. t = new Date()
  14. Project.findById key, (err, project)->
  15. total = new Date()-t
  16. cb(null, total)
  17. a = [0..10]
  18. async.mapSeries a, findAndTime, (err, times)->
  19. result =
  20. average: _.sum(times) / a.length
  21. times : times
  22. callback(null, result)
  23.  
  24. jobs =
  25. warmup: (cb)->
  26. tenRuns warmup, cb
  27. smallproject: (cb)->
  28. tenRuns smallproject, cb
  29. twokproject: (cb)->
  30. tenRuns twokproject, cb
  31. fourkproject: (cb)->
  32. tenRuns fourkproject, cb
  33. realmassive: (cb)->
  34. tenRuns realmassive, cb
  35.  
  36. async.series jobs, (err, results)->
  37. console.log results
  38. process.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement