napi-rs/bench/buffer.ts

24 lines
411 B
TypeScript
Raw Permalink Normal View History

import b from 'benny'
const { benchCreateBuffer } = require('./index.node')
function createBuffer() {
const buf = Buffer.allocUnsafe(1024)
buf[0] = 1
buf[1] = 2
return buf
}
export const benchBuffer = () =>
b.suite(
'Create buffer',
b.add('napi-rs', () => {
benchCreateBuffer()
}),
b.add('JavaScript', () => {
createBuffer()
}),
b.cycle(),
b.complete(),
)