41 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
44 static pthread_mutex_t packet_profile_lock;
45 static FILE *packet_profile_csv_fp = NULL;
57 #ifdef PROFILE_LOCKING
96 static int profiling_packets_csv_enabled = 0;
97 static int profiling_packets_output_to_file = 0;
98 static char *profiling_file_name;
99 static char profiling_packets_file_name[PATH_MAX];
100 static char *profiling_csv_file_name;
101 static const char *profiling_packets_file_mode =
"a";
114 static void PrintCSVHeader(
void);
116 static void FormatNumber(uint64_t num,
char *
str,
size_t size)
119 snprintf(
str, size,
"%"PRIu64, num);
120 else if (num < 1000000UL)
121 snprintf(
str, size,
"%3.1fk", (
float)num/1000UL);
122 else if (num < 1000000000UL)
123 snprintf(
str, size,
"%3.1fm", (
float)num/1000000UL);
125 snprintf(
str, size,
"%3.1fb", (
float)num/1000000000UL);
140 if (rate_v > 0 && rate_v < INT_MAX) {
143 SCLogInfo(
"profiling runs for every %dth packet", rate);
145 SCLogInfo(
"profiling runs for every packet");
153 if (pthread_mutex_init(&packet_profile_lock, NULL) != 0) {
154 FatalError(
"Failed to initialize packet profiling mutex.");
162 FatalError(
"Failed to allocate packet_profile_app_data4");
166 FatalError(
"Failed to allocate packet_profile_app_data6");
177 if (filename != NULL) {
179 strlcpy(profiling_packets_file_name, filename,
180 sizeof(profiling_packets_file_name));
183 snprintf(profiling_packets_file_name,
sizeof(profiling_packets_file_name),
184 "%s/%s", log_dir, filename);
189 profiling_packets_file_mode =
"a";
191 profiling_packets_file_mode =
"w";
194 profiling_packets_output_to_file = 1;
202 if (filename == NULL) {
203 filename =
"packet_profile.csv";
206 profiling_csv_file_name =
SCStrdup(filename);
207 if (
unlikely(profiling_csv_file_name == NULL)) {
211 profiling_csv_file_name =
SCMalloc(PATH_MAX);
212 if (
unlikely(profiling_csv_file_name == NULL)) {
217 snprintf(profiling_csv_file_name, PATH_MAX,
"%s/%s", log_dir, filename);
220 packet_profile_csv_fp = fopen(profiling_csv_file_name,
"w");
221 if (packet_profile_csv_fp == NULL) {
222 SCFree(profiling_csv_file_name);
223 profiling_csv_file_name = NULL;
229 profiling_packets_csv_enabled = 1;
237 #ifndef PROFILE_LOCKING
239 "lock profiling not compiled in. Add --enable-profiling-locks to configure.");
246 if (filename != NULL) {
287 pthread_mutex_destroy(&packet_profile_lock);
290 if (profiling_packets_csv_enabled) {
291 if (packet_profile_csv_fp != NULL)
292 fclose(packet_profile_csv_fp);
293 packet_profile_csv_fp = NULL;
296 if (profiling_csv_file_name != NULL)
297 SCFree(profiling_csv_file_name);
298 profiling_csv_file_name = NULL;
300 if (profiling_file_name != NULL)
301 SCFree(profiling_file_name);
302 profiling_file_name = NULL;
304 #ifdef PROFILE_LOCKING
313 SCLogPerf(
"Done dumping profiling data.");
316 static void DumpFlowWorkerIP(FILE *fp,
int ipv, uint64_t total)
323 for (
int p = 0;
p < 257;
p++) {
329 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
330 double percent = (
long double)pd->
tot /
331 (
long double)total * 100;
333 fprintf(fp,
"%-20s IPv%d %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
335 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
340 static void DumpFlowWorker(FILE *fp)
347 for (
int p = 0;
p < 257;
p++) {
355 fprintf(fp,
"\n%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
356 "Flow Worker",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg");
357 fprintf(fp,
"%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
358 "--------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------");
359 DumpFlowWorkerIP(fp, 4, total);
360 DumpFlowWorkerIP(fp, 6, total);
361 fprintf(fp,
"Note: %s includes app-layer for TCP\n",
374 if (profiling_packets_output_to_file == 1) {
375 fp = fopen(profiling_packets_file_name, profiling_packets_file_mode);
378 SCLogError(
"failed to open %s: %s", profiling_packets_file_name, strerror(errno));
385 fprintf(fp,
"\n\nPacket profile dump:\n");
387 fprintf(fp,
"\n%-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s\n",
388 "IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
389 fprintf(fp,
"%-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s\n",
390 "------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
392 for (
int i = 0; i < 257; i++) {
399 for (
int i = 0; i < 257; i++) {
405 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
406 double percent = (
long double)pd->
tot /
407 (
long double)total * 100;
409 fprintf(fp,
" IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n", i, pd->
cnt,
410 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
413 for (
int i = 0; i < 257; i++) {
419 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
420 double percent = (
long double)pd->
tot /
421 (
long double)total * 100;
423 fprintf(fp,
" IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n", i, pd->
cnt,
424 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
426 fprintf(fp,
"Note: Protocol 256 tracks pseudo/tunnel packets.\n");
428 fprintf(fp,
"\nPer Thread module stats:\n");
430 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
431 "Thread Module",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
432 #ifdef PROFILE_LOCKING
433 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
434 "locks",
"ticks",
"cont.",
"cont.avg",
"slocks",
"sticks",
"scont.",
"scont.avg");
438 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
439 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
440 #ifdef PROFILE_LOCKING
441 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
442 "--------",
"--------",
"----------",
"-----------",
"--------",
"--------",
"------------",
"-----------");
448 for (
int p = 0;
p < 257;
p++) {
458 for (
int p = 0;
p < 257;
p++) {
464 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
465 double percent = (
long double)pd->
tot /
466 (
long double)total * 100;
468 fprintf(fp,
"%-24s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f",
470 #ifdef PROFILE_LOCKING
471 fprintf(fp,
" %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f\n",
472 (
float)pd->lock/pd->
cnt, (uint64_t)pd->ticks/pd->
cnt, pd->contention, (
float)pd->contention/pd->
cnt, (
float)pd->slock/pd->
cnt, (uint64_t)pd->sticks/pd->
cnt, pd->scontention, (
float)pd->scontention/pd->
cnt);
480 for (
int p = 0;
p < 257;
p++) {
486 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
487 double percent = (
long double)pd->
tot /
488 (
long double)total * 100;
490 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n",
497 fprintf(fp,
"\nPer App layer parser stats:\n");
499 fprintf(fp,
"\n%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
500 "App Layer",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg");
501 fprintf(fp,
"%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
502 "--------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------");
506 for (
int p = 0;
p < 257;
p++) {
515 for (
int p = 0;
p < 257;
p++) {
521 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
522 double percent = (
long double)pd->
tot /
523 (
long double)total * 100;
526 "%-20s IPv4 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
527 " %12" PRIu64
" %12s %-6.2f\n",
529 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
534 for (
int p = 0;
p < 257;
p++) {
540 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
541 double percent = (
long double)pd->
tot /
542 (
long double)total * 100;
545 "%-20s IPv6 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
546 " %12" PRIu64
" %12s %-6.2f\n",
548 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
554 for (
int p = 0;
p < 257;
p++) {
560 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
561 fprintf(fp,
"%-20s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s\n",
562 "Proto detect",
p, pd->
cnt, pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr);
565 for (
int p = 0;
p < 257;
p++) {
571 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
572 fprintf(fp,
"%-20s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s\n",
573 "Proto detect",
p, pd->
cnt, pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr);
579 for (
int p = 0;
p < 257;
p++) {
588 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
589 "Log Thread Module",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
590 #ifdef PROFILE_LOCKING
591 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
592 "locks",
"ticks",
"cont.",
"cont.avg",
"slocks",
"sticks",
"scont.",
"scont.avg");
596 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
597 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
598 #ifdef PROFILE_LOCKING
599 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
600 "--------",
"--------",
"----------",
"-----------",
"--------",
"--------",
"------------",
"-----------");
606 for (
int p = 0;
p < 257;
p++) {
616 for (
int p = 0;
p < 257;
p++) {
622 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
623 double percent = (
long double)pd->
tot /
624 (
long double)total * 100;
626 fprintf(fp,
"%-24s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f",
628 #ifdef PROFILE_LOCKING
629 fprintf(fp,
" %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f\n",
630 (
float)pd->lock/pd->
cnt, (uint64_t)pd->ticks/pd->
cnt, pd->contention, (
float)pd->contention/pd->
cnt, (
float)pd->slock/pd->
cnt, (uint64_t)pd->sticks/pd->
cnt, pd->scontention, (
float)pd->scontention/pd->
cnt);
638 for (
int p = 0;
p < 257;
p++) {
644 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
645 double percent = (
long double)pd->
tot /
646 (
long double)total * 100;
648 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n",
653 fprintf(fp,
"\nLogger/output stats:\n");
657 for (
int p = 0;
p < 256;
p++) {
665 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
666 "Logger",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot");
667 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
668 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------");
670 for (
int p = 0;
p < 256;
p++) {
676 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
677 double percent = (
long double)pd->
tot /
678 (
long double)total * 100;
681 "%-24s IPv4 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
682 " %12" PRIu64
" %12s %-6.2f\n",
684 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
688 for (
int p = 0;
p < 256;
p++) {
694 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
695 double percent = (
long double)pd->
tot /
696 (
long double)total * 100;
699 "%-24s IPv6 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
700 " %12" PRIu64
" %12s %-6.2f\n",
702 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
706 fprintf(fp,
"\nGeneral detection engine stats:\n");
710 for (
int p = 0;
p < 257;
p++) {
718 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
719 "Detection phase",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot");
720 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
721 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------");
723 for (
int p = 0;
p < 257;
p++) {
729 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
730 double percent = (
long double)pd->
tot /
731 (
long double)total * 100;
733 fprintf(fp,
"%-24s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
738 for (
int p = 0;
p < 257;
p++) {
744 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
745 double percent = (
long double)pd->
tot /
746 (
long double)total * 100;
748 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
755 static void PrintCSVHeader(
void)
757 fprintf(packet_profile_csv_fp,
"pcap_cnt,total,receive,decode,flowworker,");
758 fprintf(packet_profile_csv_fp,
"threading,");
759 fprintf(packet_profile_csv_fp,
"proto detect,");
764 fprintf(packet_profile_csv_fp,
"loggers,");
776 fprintf(packet_profile_csv_fp,
"\n");
781 if (profiling_packets_csv_enabled == 0 ||
p == NULL ||
782 packet_profile_csv_fp == NULL ||
p->
profile == NULL) {
786 uint64_t tmm_total = 0;
787 uint64_t receive = 0;
792 fprintf(packet_profile_csv_fp,
"%" PRIu64
",%" PRIu64
",",
PcapPacketCntGet(
p), delta);
794 for (
int i = 0; i <
TMM_SIZE; i++) {
811 tmm_total += tmm_delta;
813 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", receive);
814 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", decode);
817 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", delta - tmm_total);
820 uint64_t app_total = 0;
824 if (
p->
proto == IPPROTO_TCP) {
836 ticks_spent -= app_total;
838 ticks_spent = app_total;
841 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", ticks_spent);
845 uint64_t loggers = 0;
850 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", loggers);
856 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", pdt->
ticks_spent);
862 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", pd->
ticks_spent);
865 fprintf(packet_profile_csv_fp,
"\n");
891 static void SCProfilingUpdatePacketDetectRecords(
Packet *
p)
898 if (PacketIsIPv4(
p)) {
899 SCProfilingUpdatePacketDetectRecord(i,
p->
proto, pdt, 4);
901 SCProfilingUpdatePacketDetectRecord(i,
p->
proto, pdt, 6);
907 static void SCProfilingUpdatePacketAppPdRecord(uint8_t ipproto, uint32_t ticks_spent,
int ipver)
915 if (pd->
min == 0 || ticks_spent < pd->min) {
916 pd->
min = ticks_spent;
918 if (pd->
max < ticks_spent) {
919 pd->
max = ticks_spent;
922 pd->
tot += ticks_spent;
926 static void SCProfilingUpdatePacketAppRecord(
int alproto, uint8_t ipproto,
PktProfilingAppData *pdt,
int ipver)
949 static void SCProfilingUpdatePacketAppRecords(
Packet *
p)
956 if (PacketIsIPv4(
p)) {
957 SCProfilingUpdatePacketAppRecord(i,
p->
proto, pdt, 4);
959 SCProfilingUpdatePacketAppRecord(i,
p->
proto, pdt, 6);
965 if (PacketIsIPv4(
p)) {
986 if (pd->
min == 0 || delta < pd->min) {
989 if (pd->
max < delta) {
993 pd->
tot += (uint64_t)delta;
996 #ifdef PROFILE_LOCKING
997 pd->lock += pdt->mutex_lock_cnt;
998 pd->ticks += pdt->mutex_lock_wait_ticks;
999 pd->contention += pdt->mutex_lock_contention;
1000 pd->slock += pdt->spin_lock_cnt;
1001 pd->sticks += pdt->spin_lock_wait_ticks;
1002 pd->scontention += pdt->spin_lock_contention;
1006 static void SCProfilingUpdatePacketTmmRecords(
Packet *
p)
1016 if (PacketIsIPv4(
p)) {
1017 SCProfilingUpdatePacketTmmRecord(i,
p->
proto, pdt, 4);
1019 SCProfilingUpdatePacketTmmRecord(i,
p->
proto, pdt, 6);
1024 static inline void SCProfilingUpdatePacketGenericRecord(
PktProfilingData *pdt,
1027 if (pdt == NULL || pd == NULL) {
1032 if (pd->
min == 0 || delta < pd->min) {
1035 if (pd->
max < delta) {
1047 for (i = 0; i < size; i++) {
1057 if (PacketIsIPv4(
p)) {
1063 SCProfilingUpdatePacketGenericRecord(pdt, store);
1067 static void SCProfilingUpdatePacketLogRecord(
LoggerId id,
1091 static void SCProfilingUpdatePacketLogRecords(
Packet *
p)
1097 if (PacketIsIPv4(
p)) {
1098 SCProfilingUpdatePacketLogRecord(i,
p->
proto, pdt, 4);
1100 SCProfilingUpdatePacketLogRecord(i,
p->
proto, pdt, 6);
1113 pthread_mutex_lock(&packet_profile_lock);
1116 if (PacketIsIPv4(
p)) {
1120 if (pd->
min == 0 || delta < pd->min) {
1123 if (pd->
max < delta) {
1130 if (PacketIsTunnel(
p)) {
1133 if (pd->
min == 0 || delta < pd->min) {
1136 if (pd->
max < delta) {
1147 SCProfilingUpdatePacketTmmRecords(
p);
1148 SCProfilingUpdatePacketAppRecords(
p);
1149 SCProfilingUpdatePacketDetectRecords(
p);
1150 SCProfilingUpdatePacketLogRecords(
p);
1152 }
else if (PacketIsIPv6(
p)) {
1156 if (pd->
min == 0 || delta < pd->min) {
1159 if (pd->
max < delta) {
1166 if (PacketIsTunnel(
p)) {
1169 if (pd->
min == 0 || delta < pd->min) {
1172 if (pd->
max < delta) {
1183 SCProfilingUpdatePacketTmmRecords(
p);
1184 SCProfilingUpdatePacketAppRecords(
p);
1185 SCProfilingUpdatePacketDetectRecords(
p);
1186 SCProfilingUpdatePacketLogRecords(
p);
1189 if (profiling_packets_csv_enabled)
1193 pthread_mutex_unlock(&packet_profile_lock);
1199 if (sample % rate == 0)
1207 #ifdef PROFILE_LOCKING
1218 if ((sample % rate) == 0) {
1225 #define CASE_CODE(E) case E: return #E
1303 ProfilingGenericTicksTest01(
void)
1305 #define TEST_RUNS 1024
1306 uint64_t ticks_start = 0;
1307 uint64_t ticks_end = 0;
1316 printf(
"malloc(1024) %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1323 printf(
"SCFree(1024) %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1332 printf(
"SCMutexInit() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1339 printf(
"SCMutexLock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1346 printf(
"SCMutexUnlock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1353 printf(
"SCMutexDestroy() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1362 printf(
"SCSpinInit() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1369 printf(
"SCSpinLock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1376 printf(
"SCSpinUnlock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1383 printf(
"SCSpinDestroy() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1391 printf(
"SC_ATOMIC_ADD %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1398 printf(
"SC_ATOMIC_CAS %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1408 UtRegisterTest(
"ProfilingGenericTicksTest01", ProfilingGenericTicksTest01);
1425 static uint64_t rate = 0;
1435 intmax_t rate_v = 0;
1439 if (rate_v > 0 && rate_v < INT_MAX) {
1440 int literal_rate = (int)rate_v;
1441 for (
int i = literal_rate; i >= 1; i--) {
1443 if ((i & (i - 1)) == 0) {
1449 SCLogInfo(
"profiling runs for every %luth packet", rate + 1);
1451 SCLogInfo(
"profiling runs for every packet");
1472 if ((sample & rate) == 0) {