just-exec.benchmark.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 doSomethingVerySimple = Machine.build(require('./private/do-something-very-simple.fixture'));
  16. var doSomethingNormal = Machine.build(require('./private/do-something-normal.fixture'));
  17. var doSomethingNormalWithComplexExemplars = Machine.build(require('./private/do-something-normal-with-complex-exemplars.fixture'));
  18. var doSomethingInsaneWithManyBasicExemplars = Machine.build(require('./private/do-something-insane-with-many-basic-exemplars.fixture'));
  19. var doSomethingInsaneButCacheableWithManyBasicExemplars = Machine.build(require('./private/do-something-insane-but-cacheable-with-many-basic-exemplars.fixture'));
  20. var doSomethingInsaneWithManyComplexExemplars = Machine.build(require('./private/do-something-insane-with-many-complex-exemplars.fixture'));
  21. var doSomethingInsaneWithManyRefExemplars = Machine.build(require('./private/do-something-insane-with-many-ref-exemplars.fixture'));
  22. var SAMPLE_USERS = require('./private/sample-users.fixture');
  23. var SAMPLE_SPECIES = require('./private/sample-species.fixture');
  24. var SAMPLE_MANY_BASIC_ARGINS = require('./private/sample-many-basic-argins.fixture');
  25. var SAMPLE_MANY_COMPLEX_ARGINS = require('./private/sample-many-complex-argins.fixture');
  26. // ╔╗ ╔═╗╔╗╔╔═╗╦ ╦╔╦╗╔═╗╦═╗╦╔═╔═╗
  27. // ╠╩╗║╣ ║║║║ ╠═╣║║║╠═╣╠╦╝╠╩╗╚═╗
  28. // ╚═╝╚═╝╝╚╝╚═╝╩ ╩╩ ╩╩ ╩╩╚═╩ ╩╚═╝
  29. describe('benchmark :: just .exec() (assuming machines have already been built)', function (){
  30. // Set "timeout" and "slow" thresholds incredibly high
  31. // to avoid running into issues.
  32. this.slow(240000);
  33. this.timeout(240000);
  34. it('should be performant enough', function (done){
  35. runBenchmarks('just .exec()', [
  36. function sanity_check(next){
  37. // Do nothing.
  38. return next();
  39. },
  40. function exec_very_simple_machine(next){
  41. doSomethingVerySimple({}).exec(next);
  42. },
  43. function exec_machine_with_inputs_and_exits_but_nothing_crazy(next){
  44. doSomethingNormal({
  45. flavor: 'Sadness',
  46. qty: 1000,
  47. foo: 'wha',
  48. bar: 'huh?'
  49. }).exec(next);
  50. },
  51. function exec_machine_with_inputs_and_exits_that_have_big_ole_exemplars(next){
  52. doSomethingNormalWithComplexExemplars({
  53. // Note:
  54. // > We just abritarily use samples from the exemplars as argmts so this
  55. // > benchmark is easier to read.
  56. users: SAMPLE_USERS,
  57. availableSpecies: SAMPLE_SPECIES,
  58. foo: SAMPLE_USERS,
  59. bar: SAMPLE_USERS
  60. }).exec(next);
  61. },
  62. function exec_machine_with_crazy_numbers_of_inputs_and_exits(next){
  63. doSomethingInsaneWithManyBasicExemplars(SAMPLE_MANY_BASIC_ARGINS).exec(next);
  64. },
  65. function exec_machine_with_crazy_numbers_of_inputs_and_exits_and_is_cacheable(next){
  66. doSomethingInsaneButCacheableWithManyBasicExemplars(SAMPLE_MANY_BASIC_ARGINS).exec(next);
  67. },
  68. function exec_machine_with_crazy_numbers_of_inputs_and_exits_with_huge_exemplars(next){
  69. doSomethingInsaneWithManyComplexExemplars(SAMPLE_MANY_COMPLEX_ARGINS).exec(next);
  70. },
  71. function exec_machine_with_crazy_numbers_of_inputs_and_exits_with_ref_exemplars(next){
  72. doSomethingInsaneWithManyRefExemplars(SAMPLE_MANY_COMPLEX_ARGINS).exec(next);
  73. },
  74. ], done);
  75. });//</should be performant enough>
  76. });