get_paramnames.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*!
  2. * utility - benchmark/get_paramnames.js
  3. * Copyright(c) 2013 fengmk2 <fengmk2@gmail.com>
  4. * MIT Licensed
  5. */
  6. "use strict";
  7. /**
  8. * Module dependencies.
  9. */
  10. var utils = require('../');
  11. var Benchmark = require('benchmark');
  12. var suite = new Benchmark.Suite();
  13. var foo = function (cid, startDate, endDate, rate, callback) {
  14. console.log('Date.now(): %j', Date.now());
  15. console.log('Date.now(): %j', Date.now());
  16. console.log('Date.now(): %j', Date.now());
  17. console.log('Date.now(): %j', Date.now());
  18. console.log('Date.now(): %j', Date.now());
  19. console.log('Date.now(): %j', Date.now());
  20. console.log('Date.now(): %j', Date.now());
  21. console.log('Date.now(): %j', Date.now());
  22. console.log('Date.now(): %j', Date.now());
  23. console.log('Date.now(): %j', Date.now());
  24. console.log('Date.now(): %j', Date.now());
  25. console.log('Date.now(): %j', Date.now());
  26. console.log('Date.now(): %j', Date.now());
  27. console.log('Date.now(): %j', Date.now());
  28. console.log('Date.now(): %j', Date.now());
  29. console.log('Date.now(): %j', Date.now());
  30. console.log('Date.now(): %j', Date.now());
  31. console.log('Date.now(): %j', Date.now());
  32. };
  33. console.log('cache:', utils.getParamNames(foo));
  34. console.log('no cache:', utils.getParamNames(foo, false));
  35. console.log('------------------------');
  36. suite
  37. .add("utils.getParamNames(foo)", function () {
  38. utils.getParamNames(foo);
  39. })
  40. .add("utils.getParamNames(foo, false) no cache", function () {
  41. utils.getParamNames(foo, false);
  42. })
  43. // add listeners
  44. .on('cycle', function (event) {
  45. console.log(String(event.target));
  46. })
  47. .on('complete', function () {
  48. console.log('Fastest is ' + this.filter('fastest').pluck('name'));
  49. })
  50. .run({ async: false });