Give real variable names to SegmentProfiler objects when defining them (bugprone-unused-raii)

The reason behind this one is that without a real variable name, the profile objects are immediately desctructed and the profiling only happens for the small window when they were valid. If the intention is to profile the method where they were defined, this doesn't actually happen.
This commit is contained in:
Tim Wojtulewicz 2020-02-03 18:15:38 -05:00
parent 3572e38ec2
commit c5748e4494
4 changed files with 5 additions and 5 deletions

View file

@ -152,7 +152,7 @@ void EventMgr::Drain()
if ( event_queue_flush_point ) if ( event_queue_flush_point )
QueueEventFast(event_queue_flush_point, val_list{}); QueueEventFast(event_queue_flush_point, val_list{});
SegmentProfiler(segment_logger, "draining-events"); SegmentProfiler prof(segment_logger, "draining-events");
PLUGIN_HOOK_VOID(HOOK_DRAIN_EVENTS, HookDrainEvents()); PLUGIN_HOOK_VOID(HOOK_DRAIN_EVENTS, HookDrainEvents());

View file

@ -309,7 +309,7 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
#ifdef PROFILE_BRO_FUNCTIONS #ifdef PROFILE_BRO_FUNCTIONS
DEBUG_MSG("Function: %s\n", Name()); DEBUG_MSG("Function: %s\n", Name());
#endif #endif
SegmentProfiler(segment_logger, location); SegmentProfiler prof(segment_logger, location);
if ( sample_logger ) if ( sample_logger )
sample_logger->FunctionSeen(this); sample_logger->FunctionSeen(this);
@ -629,7 +629,7 @@ Val* BuiltinFunc::Call(val_list* args, Frame* parent) const
#ifdef PROFILE_BRO_FUNCTIONS #ifdef PROFILE_BRO_FUNCTIONS
DEBUG_MSG("Function: %s\n", Name()); DEBUG_MSG("Function: %s\n", Name());
#endif #endif
SegmentProfiler(segment_logger, Name()); SegmentProfiler prof(segment_logger, Name());
if ( sample_logger ) if ( sample_logger )
sample_logger->FunctionSeen(this); sample_logger->FunctionSeen(this);

View file

@ -212,7 +212,7 @@ void net_init(const std::optional<std::string>& interface,
void expire_timers(iosource::PktSrc* src_ps) void expire_timers(iosource::PktSrc* src_ps)
{ {
SegmentProfiler(segment_logger, "expiring-timers"); SegmentProfiler prof(segment_logger, "expiring-timers");
current_dispatched += current_dispatched +=
timer_mgr->Advance(network_time, timer_mgr->Advance(network_time,

View file

@ -120,7 +120,7 @@ void NetSessions::Done()
void NetSessions::NextPacket(double t, const Packet* pkt) void NetSessions::NextPacket(double t, const Packet* pkt)
{ {
SegmentProfiler(segment_logger, "dispatching-packet"); SegmentProfiler prof(segment_logger, "dispatching-packet");
if ( raw_packet ) if ( raw_packet )
mgr.QueueEventFast(raw_packet, {pkt->BuildPktHdrVal()}); mgr.QueueEventFast(raw_packet, {pkt->BuildPktHdrVal()});