Files
Matteo Collina 9f04fcd70d ffi: enable module by default
Enable node:ffi by default in builds with FFI support. Keep
--experimental-ffi as a compatibility no-op and --no-experimental-ffi as
an opt-out. Loading the module still emits an experimental warning.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/65475
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-08-28 00:23:11 +00:00

32 lines
668 B
JavaScript

'use strict';
const common = require('../common.js');
const ffi = require('node:ffi');
const { libraryPath, ensureFixtureLibrary } = require('./common.js');
const bench = common.createBenchmark(main, {
size: [64, 1024, 16384],
n: [1e6],
});
ensureFixtureLibrary();
const { lib, functions } = ffi.dlopen(libraryPath, {
sum_buffer: { return: 'u64', arguments: ['pointer', 'u64'] },
});
function main({ n, size }) {
const buf = Buffer.alloc(size, 0x42);
const ptr = ffi.getRawPointer(buf);
const len = BigInt(size);
const sum = functions.sum_buffer;
bench.start();
for (let i = 0; i < n; ++i)
sum(ptr, len);
bench.end(n);
lib.close();
}