2020-12-21 17:10:30 +09:00
|
|
|
import b from 'benny'
|
|
|
|
|
|
|
|
const { benchCreateBuffer } = require('./index.node')
|
|
|
|
|
|
|
|
function createBuffer() {
|
2021-06-22 00:09:13 +09:00
|
|
|
const buf = Buffer.allocUnsafe(1024)
|
2020-12-21 17:10:30 +09:00
|
|
|
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(),
|
|
|
|
)
|