build.benchmark.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * Module dependencies
  3. */
  4. var runBenchmarks = require('../util/run-benchmarks.helper');
  5. var Machine = require('../../');
  6. /* eslint-disable no-unused-vars, camelcase */
  7. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  8. // ^^because the snake_case makes test output more readable when working with
  9. // the benchmark.js lib, and the unused vars are there on purpose (to help
  10. // make sure that nothing gets optimized away by V8).
  11. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  12. // ╔═╗╦═╗ ╦╔╦╗╦ ╦╦═╗╔═╗╔═╗
  13. // ╠╣ ║╔╩╦╝ ║ ║ ║╠╦╝║╣ ╚═╗
  14. // ╚ ╩╩ ╚═ ╩ ╚═╝╩╚═╚═╝╚═╝
  15. var DO_SOMETHING_VERY_SIMPLE = require('./private/do-something-very-simple.fixture');
  16. var DO_SOMETHING_NORMAL = require('./private/do-something-normal.fixture');
  17. var DO_SOMETHING_NORMAL_WITH_COMPLEX_EXEMPLARS = require('./private/do-something-normal-with-complex-exemplars.fixture');
  18. var DO_SOMETHING_INSANE_WITH_MANY_BASIC_EXEMPLARS = require('./private/do-something-insane-with-many-basic-exemplars.fixture');
  19. var DO_SOMETHING_INSANE_BUT_CACHEABLE_WITH_MANY_BASIC_EXEMPLARS = require('./private/do-something-insane-but-cacheable-with-many-basic-exemplars.fixture');
  20. var DO_SOMETHING_INSANE_WITH_MANY_COMPLEX_EXEMPLARS = require('./private/do-something-insane-with-many-complex-exemplars.fixture');
  21. var DO_SOMETHING_INSANE_WITH_MANY_REF_EXEMPLARS = require('./private/do-something-insane-with-many-ref-exemplars.fixture');
  22. // ╔╗ ╔═╗╔╗╔╔═╗╦ ╦╔╦╗╔═╗╦═╗╦╔═╔═╗
  23. // ╠╩╗║╣ ║║║║ ╠═╣║║║╠═╣╠╦╝╠╩╗╚═╗
  24. // ╚═╝╚═╝╝╚╝╚═╝╩ ╩╩ ╩╩ ╩╩╚═╩ ╩╚═╝
  25. describe('benchmark :: Machine.build()', function (){
  26. // Set "timeout" and "slow" thresholds incredibly high
  27. // to avoid running into issues.
  28. this.slow(240000);
  29. this.timeout(240000);
  30. it('should be performant enough', function (done){
  31. // (Including this squid tentacle here just since this file is alphabetically first.)
  32. console.log(
  33. ' \n'+
  34. ' o \n'+
  35. ' \n'+
  36. ' • \n'+
  37. ' o . \n'+
  38. ' • • \n'+
  39. ' • • \n'+
  40. ' • o \n'+
  41. ' • o\n'+
  42. ' o • • o •\n'+
  43. ' o o • \n'+
  44. ' • • • • • • \n'+
  45. ' • • o \n'+
  46. ' • b e n c h m a r k s • \n'+
  47. ' • • \n'+
  48. ' • ___ • \n'+
  49. ' • o • • • /o/•\\_ • \n'+
  50. ' • • o • /_/\\ o \\_ • \n'+
  51. ' o O • o • • \\ o .\\_ \n'+
  52. ' • o • \\. O \\ \n'+
  53. '');
  54. runBenchmarks('just Machine.build()', [
  55. function sanity_check(next){
  56. // Do nothing.
  57. return next();
  58. },
  59. function build_very_simple_machine(next){
  60. var m = Machine.build(DO_SOMETHING_VERY_SIMPLE);
  61. return next();
  62. },
  63. function build_machine_with_inputs_and_exits_but_nothing_crazy(next){
  64. var m = Machine.build(DO_SOMETHING_NORMAL);
  65. return next();
  66. },
  67. function build_machine_with_inputs_and_exits_that_have_big_ole_exemplars(next){
  68. var m = Machine.build(DO_SOMETHING_NORMAL_WITH_COMPLEX_EXEMPLARS);
  69. return next();
  70. },
  71. function build_machine_with_crazy_numbers_of_inputs_and_exits(next){
  72. var m = Machine.build(DO_SOMETHING_INSANE_WITH_MANY_BASIC_EXEMPLARS);
  73. return next();
  74. },
  75. function build_machine_with_crazy_numbers_of_inputs_and_exits_and_is_cacheable(next){
  76. var m = Machine.build(DO_SOMETHING_INSANE_BUT_CACHEABLE_WITH_MANY_BASIC_EXEMPLARS);
  77. return next();
  78. },
  79. function build_machine_with_crazy_numbers_of_inputs_and_exits_with_huge_exemplars(next){
  80. var m = Machine.build(DO_SOMETHING_INSANE_WITH_MANY_COMPLEX_EXEMPLARS);
  81. return next();
  82. },
  83. function build_machine_with_crazy_numbers_of_inputs_and_exits_with_ref_exemplars(next){
  84. var m = Machine.build(DO_SOMETHING_INSANE_WITH_MANY_REF_EXEMPLARS);
  85. return next();
  86. },
  87. ], done);
  88. });//</should be performant enough>
  89. });