summaryrefslogtreecommitdiff
path: root/benchmark/napi/ref/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/napi/ref/index.js')
-rw-r--r--benchmark/napi/ref/index.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/benchmark/napi/ref/index.js b/benchmark/napi/ref/index.js
new file mode 100644
index 0000000000..3a5e198827
--- /dev/null
+++ b/benchmark/napi/ref/index.js
@@ -0,0 +1,17 @@
+'use strict';
+const common = require('../../common');
+const addon = require(`./build/${common.buildType}/addon`);
+const bench = common.createBenchmark(main, { n: [1e7] });
+
+function callNewWeak() {
+ addon.newWeak();
+}
+
+function main({ n }) {
+ addon.count = 0;
+ bench.start();
+ while (addon.count < n) {
+ callNewWeak();
+ }
+ bench.end(n);
+}