escapeId.js 798 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. var benchmark = require('benchmark');
  2. var benchmarks = require('beautify-benchmark');
  3. global.SqlString = require('..');
  4. var suite = new benchmark.Suite();
  5. suite.add({
  6. name : '"col"',
  7. minSamples : 100,
  8. fn : 'var val = SqlString.escapeId("col");'
  9. });
  10. suite.add({
  11. name : '"tbl.col"',
  12. minSamples : 100,
  13. fn : 'var val = SqlString.escapeId("tbl.col");'
  14. });
  15. suite.add({
  16. name : '["col1", "col2"]',
  17. minSamples : 100,
  18. fn : 'var val = SqlString.escapeId(["col1", "col2"]);'
  19. });
  20. suite.on('start', function onCycle() {
  21. process.stdout.write(' escapeId\n\n');
  22. });
  23. suite.on('cycle', function onCycle(event) {
  24. benchmarks.add(event.target);
  25. });
  26. suite.on('complete', function onComplete() {
  27. benchmarks.log();
  28. });
  29. suite.run({async: false});