bench: Buffer creation
authorisaacs <i@izs.me>
Mon, 11 Feb 2013 21:41:16 +0000 (13:41 -0800)
committerisaacs <i@izs.me>
Tue, 19 Feb 2013 22:14:32 +0000 (14:14 -0800)
benchmark/buffer_creation.js [deleted file]
benchmark/buffers/buffer_creation.js [new file with mode: 0644]

diff --git a/benchmark/buffer_creation.js b/benchmark/buffer_creation.js
deleted file mode 100644 (file)
index 3bc711e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-SlowBuffer = require('buffer').SlowBuffer;
-
-for (var i = 0; i < 1e6; i++) {
-  b = new SlowBuffer(10);
-  b[1] = 2
-}
diff --git a/benchmark/buffers/buffer_creation.js b/benchmark/buffers/buffer_creation.js
new file mode 100644 (file)
index 0000000..d1d91f0
--- /dev/null
@@ -0,0 +1,17 @@
+SlowBuffer = require('buffer').SlowBuffer;
+
+var common = require('../common.js');
+var bench = common.createBenchmark(main, {
+  len: [10, 1024],
+  n: [1024]
+});
+
+function main(conf) {
+  var len = +conf.len;
+  var n = +conf.n;
+  bench.start();
+  for (var i = 0; i < n * 1024; i++) {
+    b = new SlowBuffer(len);
+  }
+  bench.end(n);
+}