MCPcopy Create free account
hub / github.com/nodejs/node-addon-api / FunctionArgsBenchmark

Class FunctionArgsBenchmark

benchmark/function_args.cc:92–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90
91#if NAPI_VERSION > 5
92class FunctionArgsBenchmark : public Napi::Addon<FunctionArgsBenchmark> {
93 public:
94 FunctionArgsBenchmark(Napi::Env env, Napi::Object exports) {
95 DefineAddon(
96 exports,
97 {
98 InstanceValue(
99 "addon",
100 DefineProperties(
101 Napi::Object::New(env),
102 {
103 InstanceMethod("noArgFunction",
104 &FunctionArgsBenchmark::NoArgFunction),
105 InstanceMethod("oneArgFunction",
106 &FunctionArgsBenchmark::OneArgFunction),
107 InstanceMethod("twoArgFunction",
108 &FunctionArgsBenchmark::TwoArgFunction),
109 InstanceMethod(
110 "threeArgFunction",
111 &FunctionArgsBenchmark::ThreeArgFunction),
112 InstanceMethod("fourArgFunction",
113 &FunctionArgsBenchmark::FourArgFunction),
114 }),
115 napi_enumerable),
116 InstanceValue(
117 "addon_templated",
118 DefineProperties(
119 Napi::Object::New(env),
120 {
121 InstanceMethod<&FunctionArgsBenchmark::NoArgFunction>(
122 "noArgFunction"),
123 InstanceMethod<&FunctionArgsBenchmark::OneArgFunction>(
124 "oneArgFunction"),
125 InstanceMethod<&FunctionArgsBenchmark::TwoArgFunction>(
126 "twoArgFunction"),
127 InstanceMethod<
128 &FunctionArgsBenchmark::ThreeArgFunction>(
129 "threeArgFunction"),
130 InstanceMethod<&FunctionArgsBenchmark::FourArgFunction>(
131 "fourArgFunction"),
132 }),
133 napi_enumerable),
134 });
135 }
136
137 private:
138 void NoArgFunction(const Napi::CallbackInfo& info) { (void)info; }
139
140 void OneArgFunction(const Napi::CallbackInfo& info) {
141 Napi::Value argv0 = info[0];
142 (void)argv0;
143 }
144
145 void TwoArgFunction(const Napi::CallbackInfo& info) {
146 Napi::Value argv0 = info[0];
147 (void)argv0;
148 Napi::Value argv1 = info[1];
149 (void)argv1;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected