mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
benchmark: remove duplicate ffi string length direct
Signed-off-by: HoonDongKang <d159123@naver.com> PR-URL: https://github.com/nodejs/node/pull/66278 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
3641c36af1
commit
c97bbfb2e7
2 files changed
-28
No files matched your search
File renamed without changes.
@@ -1,28 +0,0 @@
|
||||
'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],
|
||||
});
|
||||
|
||||
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();
|
||||
}
|
||||
Reference in new issue
Block a user