expression.js 699 B

1234567891011121314151617181920212223242526272829303132333435
  1. console.log('\Expression Parser\n')
  2. var Cache = require('../src/cache')
  3. var parse = require('../src/parse/expression').parse
  4. Cache.prototype.get = Cache.prototype.put = function () {}
  5. function bench (id, fn) {
  6. var s = Date.now()
  7. var max = i = 10000
  8. while (i--) {
  9. fn()
  10. }
  11. var used = Date.now() - s
  12. var ops = Math.round(16 / (used / max))
  13. console.log(id + ': ' + ops + ' ops/frame')
  14. }
  15. var side
  16. bench('simple path', function () {
  17. side = parse('a.b.c')
  18. })
  19. bench('complex path', function () {
  20. side = parse('a["b"].c')
  21. })
  22. bench('simple exp', function () {
  23. side = parse('a.b + c')
  24. })
  25. bench('complex exp', function () {
  26. side = parse('a.b + { c: d} + "abced{fsefesf}ede"')
  27. })