md5.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*!
  2. * utility - benchmark/md5.js
  3. *
  4. * Copyright(c) 2013 fengmk2 <fengmk2@gmail.com>
  5. * MIT Licensed
  6. */
  7. "use strict";
  8. /**
  9. * Module dependencies.
  10. */
  11. var utils = require('../');
  12. var Benchmark = require('benchmark');
  13. var suite = new Benchmark.Suite();
  14. console.log("utils.md5({foo: 'bar', bar: 'foo', v: [1, 2, 3]})", utils.md5({foo: 'bar', bar: 'foo', v: [1, 2, 3]}));
  15. console.log("utils.md5(JSON.stringify({foo: 'bar', bar: 'foo', v: [1, 2, 3]}))",
  16. utils.md5(JSON.stringify({foo: 'bar', bar: 'foo', v: [1, 2, 3]})));
  17. console.log("utils.md5('苏千')", utils.md5('苏千'));
  18. console.log('------------------------');
  19. suite
  20. .add("utils.md5({foo: 'bar', bar: 'foo', v: [1, 2, 3]})", function () {
  21. utils.md5({foo: 'bar', bar: 'foo', v: [1, 2, 3]});
  22. })
  23. .add("utils.md5(JSON.stringify({foo: 'bar', bar: 'foo', v: [1, 2, 3]})))", function () {
  24. utils.md5(JSON.stringify({foo: 'bar', bar: 'foo', v: [1, 2, 3]}));
  25. })
  26. .add("utils.md5('苏千')", function () {
  27. utils.md5('苏千');
  28. })
  29. // add listeners
  30. .on('cycle', function (event) {
  31. console.log(String(event.target));
  32. })
  33. .on('complete', function () {
  34. console.log('Fastest is ' + this.filter('fastest').pluck('name'));
  35. })
  36. .run({ async: false });