Guest User

Untitled

a guest
Feb 24th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. const windowSize = 200000
  2. const msgCount = 1000000
  3. let worst = -Infinity
  4.  
  5. function mkMessage(n) {
  6. const m = []
  7. for (let i; i < 2014; i++) {
  8. m.push(n)
  9. }
  10. return m
  11. }
  12.  
  13. function pushMsg(c, highID) {
  14. const start = Date.now()
  15. const m = mkMessage(highID)
  16.  
  17. c[highID%windowSize] = m
  18.  
  19. const elapsed = Date.now() - start
  20.  
  21. if (elapsed > worst) {
  22. worst = elapsed
  23. }
  24. }
  25.  
  26. function main() {
  27. const c = []
  28.  
  29. for (let i = 0; i < msgCount; i++) {
  30. pushMsg(c, i)
  31. }
  32.  
  33. console.log(`Worst push time: ${worst}ms`)
  34. }
  35.  
  36. main()
Add Comment
Please, Sign In to add comment