/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
benchmark/ffi/string-length-string-direct.js
30 строк
642 B
Paolo Insogna
ffi: add experimental fast FFI call API for AArch64 and x86_64
16 июн 2026, 12:35
Не верифицирован
16 июн 2026, 12:35
3e55527
Код
Авторство
О чём код?
'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: ['pointer'] }, }); const fn = functions.string_length; const string = Buffer.from('hello\0'); const pointer = ffi.getRawPointer(string); function main({ n }) { bench.start(); for (let i = 0; i < n; ++i) fn(pointer); bench.end(n); lib.close(); }