Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/node_debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ using v8::Number;
using v8::Object;
using v8::Value;

thread_local std::unordered_map<std::string, int> generic_usage_counters;
thread_local std::unordered_map<FastStringKey, int, FastStringKey::Hash>
generic_usage_counters;
thread_local std::unordered_map<FastStringKey, int, FastStringKey::Hash>
v8_fast_api_call_counts;

void CountGenericUsage(const char* counter_name) {
if (generic_usage_counters.find(counter_name) == generic_usage_counters.end())
generic_usage_counters[counter_name] = 0;
void CountGenericUsage(FastStringKey counter_name) {
generic_usage_counters[counter_name]++;
}

int GetGenericUsageCount(const char* counter_name) {
int GetGenericUsageCount(FastStringKey counter_name) {
return generic_usage_counters[counter_name];
}

Expand All @@ -53,8 +52,8 @@ void GetGenericUsageCount(const FunctionCallbackInfo<Value>& args) {
return;
}
Utf8Value utf8_key(env->isolate(), args[0]);
args.GetReturnValue().Set(
GetGenericUsageCount(utf8_key.ToStringView().data()));
args.GetReturnValue().Set(GetGenericUsageCount(
FastStringKey::AllowDynamic(utf8_key.ToStringView())));
}

void GetV8FastApiCallCount(const FunctionCallbackInfo<Value>& args) {
Expand Down
5 changes: 3 additions & 2 deletions src/node_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ namespace debug {
void TrackV8FastApiCall(FastStringKey key);
int GetV8FastApiCallCount(FastStringKey key);

void CountGenericUsage(const char* counter_name);
#define COUNT_GENERIC_USAGE(name) node::debug::CountGenericUsage(name)
void CountGenericUsage(FastStringKey counter_name);
#define COUNT_GENERIC_USAGE(name) \
node::debug::CountGenericUsage(FastStringKey(name))

#define TRACK_V8_FAST_API_CALL(key) \
node::debug::TrackV8FastApiCall(FastStringKey(key))
Expand Down
Loading