char *profiling_csv_file_name;
const char *profiling_packets_file_mode = "a";
+static int rate = 1;
+static SC_ATOMIC_DECL_AND_INIT(uint64_t, samples);
+
/**
* Used as a check so we don't double enter a profiling run.
*/
{
ConfNode *conf;
+ intmax_t rate_v = 0;
+ (void)ConfGetInt("profiling.sample-rate", &rate_v);
+ if (rate_v > 0 && rate_v < INT_MAX) {
+ rate = (int)rate_v;
+ if (rate != 1)
+ SCLogInfo("profiling runs for every %dth packet", rate);
+ else
+ SCLogInfo("profiling runs for every packet");
+ }
+
conf = ConfGetNode("profiling.packets");
if (conf != NULL) {
if (ConfNodeChildValueIsTrue(conf, "enabled")) {
pthread_mutex_unlock(&packet_profile_lock);
}
-static int rate = 1;
-static SC_ATOMIC_DECL_AND_INIT(uint64_t, samples);
-
PktProfiling *SCProfilePacketStart(void) {
uint64_t sample = SC_ATOMIC_ADD(samples, 1);
if (sample % rate == 0)
# the --enable-profiling configure flag.
#
profiling:
+ # Run profiling for every xth packet. The default is 1, which means we
+ # profile every packet. If set to 1000, one packet is profiled for every
+ # 1000 received.
+ #sample-rate: 1000
# rule profiling
rules: