24 lines
407 B
TypeScript
24 lines
407 B
TypeScript
|
import b from 'benny'
|
||
|
|
||
|
const { benchCreateBuffer } = require('./index.node')
|
||
|
|
||
|
function createBuffer() {
|
||
|
const buf = Buffer.alloc(100000)
|
||
|
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(),
|
||
|
)
|