performance.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. Done,with 1000000 events, it was taking aroudn 200~400 ms
  2. for 1000000 events
  3. with new EventManager is taking 0.02 0.11ms altough we lost
  4. Event manager - revamp
  5. //Current status:
  6. //flat event listener
  7. var ctx = {};
  8. function callback() {};
  9. // ctx allows for easy removal of several events
  10. events.on(ctx,'core-shell:cmd:ls',callback);
  11. events.on(ctx,'hci-http:req:/monitor/?(.*)',callback);
  12. events.listeners = [
  13. (Listener): { context,'core-shell:cmd:ls',callback,order}
  14. (Listener): { context,'hci-http:req:/monitor/?(.*)',callback,order}
  15. ];
  16. //So when an event is fired, the listeners will be iterated and checked
  17. context.emit(name,...args);
  18. events.emit('core-shell:cmd:ls',1,2);
  19. // Contextual idea
  20. //
  21. var ctx = events.createContext();
  22. ctx.on('core-shell:cmd:ls',callback);
  23. 10000 listeners testing cases
  24. Goal:
  25. Maintain listeners even if module is gone
  26. improve performance on listener matching
  27. //
  28. var subscription = context.subscribe('hci-http')
  29. subscription.on('get:/monitor/?(.*)');
  30. subscription.on('post:/monitor');
  31. Right now if we receive a request from /monitor/api we broadcast it to anyone that's listening for hci-http
  32. meaning with
  33. as of hci-http-monitor