property_descriptor.js 783 B

1234567891011121314151617181920212223242526272829
  1. const path = require('path');
  2. const Benchmark = require('benchmark');
  3. const addonName = path.basename(__filename, '.js');
  4. [ addonName, addonName + '_noexcept' ]
  5. .forEach((addonName) => {
  6. const rootAddon = require(`./build/Release/${addonName}`);
  7. const getters = new Benchmark.Suite;
  8. const setters = new Benchmark.Suite;
  9. console.log(`${addonName}: `);
  10. Object.keys(rootAddon).forEach((key) => {
  11. getters.add(`${key} getter`, () => {
  12. const x = rootAddon[key];
  13. });
  14. setters.add(`${key} setter`, () => {
  15. rootAddon[key] = 5;
  16. })
  17. });
  18. getters
  19. .on('cycle', (event) => console.log(String(event.target)))
  20. .run();
  21. setters
  22. .on('cycle', (event) => console.log(String(event.target)))
  23. .run();
  24. });