sequelizer.test.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. var runBenchmarks = require('../support/benchmark-runner');
  2. var analyze = require('../support/analyze');
  3. var sqlBuilder = require('../../index')({
  4. dialect: 'postgres'
  5. });
  6. // ╔╗ ╔═╗╔╗╔╔═╗╦ ╦╔╦╗╔═╗╦═╗╦╔═╔═╗
  7. // ╠╩╗║╣ ║║║║ ╠═╣║║║╠═╣╠╦╝╠╩╗╚═╗
  8. // ╚═╝╚═╝╝╚╝╚═╝╩ ╩╩ ╩╩ ╩╩╚═╩ ╩╚═╝
  9. describe('Benchmark :: Sequelizer', function() {
  10. // Set "timeout" and "slow" thresholds incredibly high
  11. // to avoid running into issues.
  12. this.slow(240000);
  13. this.timeout(240000);
  14. var trees = {};
  15. // Analyzer all the test inputs before running benchmarks
  16. before(function() {
  17. trees.select = analyze({
  18. select: ['*'],
  19. from: 'books'
  20. });
  21. trees.insert = analyze({
  22. insert: {
  23. title: 'Slaughterhouse Five'
  24. },
  25. into: 'books'
  26. });
  27. trees.update = analyze({
  28. update: {
  29. status: 'archived'
  30. },
  31. where: {
  32. publishedDate: { '>': 2000 }
  33. },
  34. using: 'books'
  35. });
  36. trees.delete = analyze({
  37. del: true,
  38. from: 'accounts',
  39. where: {
  40. activated: false
  41. }
  42. });
  43. });
  44. it('should be performant enough', function() {
  45. runBenchmarks('Sequelizer.execSync()', [
  46. function sequelizerSelect() {
  47. sqlBuilder.sequelizer(trees.select);
  48. },
  49. function sequelizerInsert() {
  50. sqlBuilder.sequelizer(trees.insert);
  51. },
  52. function sequelizerUpdate() {
  53. sqlBuilder.sequelizer(trees.update);
  54. },
  55. function sequelizerDelete() {
  56. sqlBuilder.sequelizer(trees.delete);
  57. }
  58. ]);
  59. });
  60. });