Open rluvaton opened 3 years ago
The perf on the following concerns me specifically because no buffer resizing happens:
.add('SmartBuffer.write (fixed size)', function() {
const buffer = SmartBuffer.fromBuffer(Buffer.alloc(SIZE * 2));
for (let i = 0; i < SIZE; i++) {
buffer.writeUInt16LE(data[i]);
}
})
This lib does a lot of checks on buffer operations but if the factor vs regular buffers is x7 it's definitely an issue in any context where performance matters.
Do you have any suggestions?
I would remove all the unnecessary wrapping / checking (like stuff on offsets) to remove any overhead. Besides ensuring capacity, all the relevant checking is already performed by Node.js (e.g. https://github.com/nodejs/node/blob/2be596604ac13a4dd68eb9cc38e54f2df438dd97/lib/buffer.js#L1065). IMO, what is not checked by Node.js Buffer should be the responsibility of the user.
Great project man!
The only thing that concerns me is the performance issue:
The benchmark code is this ReplIt