mirror of
https://github.com/nodejs/node.git
synced 2024-11-27 22:16:50 +01:00
60d9aed307
Introduce APIs that allow for the creation of JavaScript strings without copying the underlying native string into the engine. The APIs fall back to regular string creation if the engine's external string APIs are unavailable. In this case, an optional boolean out-parameter indicates that the string was copied, and the optional finalizer is called if given. PR-URL: https://github.com/nodejs/node/pull/48339 Fixes: https://github.com/nodejs/node/issues/48198 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Signed-off-by: Gabriel Schulhof <gabrielschulhof@gmail.com>
20 lines
453 B
JavaScript
20 lines
453 B
JavaScript
'use strict';
|
|
const common = require('../../common.js');
|
|
|
|
let binding;
|
|
try {
|
|
binding = require(`./build/${common.buildType}/binding`);
|
|
} catch {
|
|
console.error(`${__filename}: Binding failed to load`);
|
|
process.exit(0);
|
|
}
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1e5, 1e6, 1e7],
|
|
stringType: ['Latin1', 'Utf8', 'Utf16'],
|
|
});
|
|
|
|
function main({ n, stringType }) {
|
|
binding[`createString${stringType}`](n, bench, bench.start, bench.end);
|
|
}
|