just-execSync.benchmark.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. * Module dependencies
  3. */
  4. var _ = require('@sailshq/lodash');
  5. var runBenchmarks = require('../util/run-benchmarks.helper');
  6. var Machine = require('../../');
  7. /* eslint-disable no-unused-vars, camelcase */
  8. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  9. // ^^because the snake_case makes test output more readable when working with
  10. // the benchmark.js lib, and the unused vars are there on purpose (to help
  11. // make sure that nothing gets optimized away by V8).
  12. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  13. // ╔═╗╦═╗ ╦╔╦╗╦ ╦╦═╗╔═╗╔═╗
  14. // ╠╣ ║╔╩╦╝ ║ ║ ║╠╦╝║╣ ╚═╗
  15. // ╚ ╩╩ ╚═ ╩ ╚═╝╩╚═╚═╝╚═╝
  16. // > Note that we extend all of the test machine defs with `sync: true`--
  17. // > a necessary step, given the nature of this particular benchmark.
  18. var doSomethingVerySimple = Machine.build(_.extend({sync: true}, require('./private/do-something-very-simple.fixture')));
  19. var doSomethingNormal = Machine.build(_.extend({sync: true}, require('./private/do-something-normal.fixture')));
  20. var doSomethingNormalWithComplexExemplars = Machine.build(_.extend({sync: true}, require('./private/do-something-normal-with-complex-exemplars.fixture')));
  21. var doSomethingInsaneWithManyBasicExemplars = Machine.build(_.extend({sync: true}, require('./private/do-something-insane-with-many-basic-exemplars.fixture')));
  22. var doSomethingInsaneButCacheableWithManyBasicExemplars = Machine.build(_.extend({sync: true}, require('./private/do-something-insane-but-cacheable-with-many-basic-exemplars.fixture')));
  23. var doSomethingInsaneWithManyComplexExemplars = Machine.build(_.extend({sync: true}, require('./private/do-something-insane-with-many-complex-exemplars.fixture')));
  24. var doSomethingInsaneWithManyRefExemplars = Machine.build(_.extend({sync: true}, require('./private/do-something-insane-with-many-ref-exemplars.fixture')));
  25. var SAMPLE_USERS = require('./private/sample-users.fixture');
  26. var SAMPLE_SPECIES = require('./private/sample-species.fixture');
  27. var SAMPLE_MANY_BASIC_ARGINS = require('./private/sample-many-basic-argins.fixture');
  28. var SAMPLE_MANY_COMPLEX_ARGINS = require('./private/sample-many-complex-argins.fixture');
  29. // ╔╗ ╔═╗╔╗╔╔═╗╦ ╦╔╦╗╔═╗╦═╗╦╔═╔═╗
  30. // ╠╩╗║╣ ║║║║ ╠═╣║║║╠═╣╠╦╝╠╩╗╚═╗
  31. // ╚═╝╚═╝╝╚╝╚═╝╩ ╩╩ ╩╩ ╩╩╚═╩ ╩╚═╝
  32. describe('benchmark :: just .execSync() (assuming machines have already been built)', function (){
  33. // Set "timeout" and "slow" thresholds incredibly high
  34. // to avoid running into issues.
  35. this.slow(240000);
  36. this.timeout(240000);
  37. it('should be performant enough', function (done){
  38. runBenchmarks('just .execSync()', [
  39. function sanity_check(next){
  40. // Do nothing.
  41. return next();
  42. },
  43. function execSync_very_simple_machine(next){
  44. doSomethingVerySimple({}).execSync();
  45. return next();
  46. },
  47. function execSync_machine_with_inputs_and_exits_but_nothing_crazy(next){
  48. doSomethingNormal({
  49. flavor: 'Sadness',
  50. qty: 1000,
  51. foo: 'wha',
  52. bar: 'huh?'
  53. }).execSync();
  54. return next();
  55. },
  56. function execSync_machine_with_inputs_and_exits_that_have_big_ole_exemplars(next){
  57. doSomethingNormalWithComplexExemplars({
  58. // Note:
  59. // > We just abritarily use samples from the exemplars as argmts so this
  60. // > benchmark is easier to read.
  61. users: SAMPLE_USERS,
  62. availableSpecies: SAMPLE_SPECIES,
  63. foo: SAMPLE_USERS,
  64. bar: SAMPLE_USERS
  65. }).execSync();
  66. return next();
  67. },
  68. function execSync_machine_with_crazy_numbers_of_inputs_and_exits(next){
  69. doSomethingInsaneWithManyBasicExemplars(SAMPLE_MANY_BASIC_ARGINS).execSync();
  70. return next();
  71. },
  72. function execSync_machine_with_crazy_numbers_of_inputs_and_exits_and_is_cacheable(next){
  73. doSomethingInsaneButCacheableWithManyBasicExemplars(SAMPLE_MANY_BASIC_ARGINS).execSync();
  74. return next();
  75. },
  76. function execSync_machine_with_crazy_numbers_of_inputs_and_exits_with_huge_exemplars(next){
  77. doSomethingInsaneWithManyComplexExemplars(SAMPLE_MANY_COMPLEX_ARGINS).execSync();
  78. return next();
  79. },
  80. function execSync_machine_with_crazy_numbers_of_inputs_and_exits_with_ref_exemplars(next){
  81. doSomethingInsaneWithManyRefExemplars(SAMPLE_MANY_COMPLEX_ARGINS).execSync();
  82. return next();
  83. },
  84. ], done);
  85. });//</should be performant enough>
  86. });