/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v26.6.0
benchmark/ffi/string-length-buffer.js
29 строк
597 B
Paolo Insogna
ffi: add experimental fast FFI call API for AArch64 and x86_64
18 июн 2026, 11:11
Не верифицирован
18 июн 2026, 11:11
f52cf5e
Код
Авторство
О чём код?
'use strict'; const common = require('../common.js'); const ffi = require('node:ffi'); const { libraryPath, ensureFixtureLibrary } = require('./common.js'); const bench = common.createBenchmark(main, { n: [1e7], }, { flags: ['--experimental-ffi'], }); ensureFixtureLibrary(); const { lib, functions } = ffi.dlopen(libraryPath, { string_length: { return: 'u64', arguments: ['buffer'] }, }); const fn = functions.string_length; const string = Buffer.from('hello\0'); function main({ n }) { bench.start(); for (let i = 0; i < n; ++i) fn(string); bench.end(n); lib.close(); }