mirror of
https://github.com/nodejs/node.git
synced 2025-05-12 09:36:17 +00:00

Move C++ benchmark useful for NAPI to its own directory. This will isolate the benchmark so it can be excluded from testing that applies to all other benchmarks but not this one. PR-URL: https://github.com/nodejs/node/pull/21046 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
27 lines
702 B
C
27 lines
702 B
C
#include <assert.h>
|
|
#include <node_api.h>
|
|
|
|
static int32_t increment = 0;
|
|
|
|
static napi_value Hello(napi_env env, napi_callback_info info) {
|
|
napi_value result;
|
|
napi_status status = napi_create_int32(env, increment++, &result);
|
|
assert(status == napi_ok);
|
|
return result;
|
|
}
|
|
|
|
NAPI_MODULE_INIT() {
|
|
napi_value hello;
|
|
napi_status status =
|
|
napi_create_function(env,
|
|
"hello",
|
|
NAPI_AUTO_LENGTH,
|
|
Hello,
|
|
NULL,
|
|
&hello);
|
|
assert(status == napi_ok);
|
|
status = napi_set_named_property(env, exports, "hello", hello);
|
|
assert(status == napi_ok);
|
|
return exports;
|
|
}
|