Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a return value to write* methods to return the offset after the…

… write* call
  • Loading branch information...
commit 3fefed9fed388ace5e600ae356677524193d8b34 1 parent 6c73f94
@catshow authored
Showing with 36 additions and 0 deletions.
  1. +36 −0 benchmark/buffer_with_offset_return.js
View
36 benchmark/buffer_with_offset_return.js
@@ -0,0 +1,36 @@
+function testBufferWithReturn(){
+ var buffer = new Buffer(50);
+ var offset = 0;
+
+ console.time('buffer with return x 100K');
+
+ for(var i = 0; i < 100000; i++){
+ offset = 0;
+
+ offset = buffer.writeUInt8(1, offset);
+
+ offset = buffer.writeUInt16BE(2, offset);
+
+ offset = buffer.writeUInt32BE(3, offset);
+
+ offset = buffer.writeInt8(-1, offset);
+
+ offset = buffer.writeInt16BE(-2, offset);
+
+ offset = buffer.writeInt32BE(-3, offset);
+
+ offset = buffer.writeFloatBE(1.234, offset);
+
+ offset = buffer.writeDoubleBE(1.234, offset);
+ }
+
+ console.timeEnd('buffer with return x 100K');
+}
+
+console.time('buffer with return x 1 Million');
+
+for(var x=0; x<10; x++){
+ testBufferWithReturn();
+}
+
+console.timeEnd('buffer with return x 1 Million');
Please sign in to comment.
Something went wrong with that request. Please try again.