Measure CPU used by the sample processing thread.
This commit is contained in:
parent
4732ad3498
commit
7a0ca85a90
2
Makefile
2
Makefile
|
@ -11,7 +11,7 @@ EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\"
|
|||
endif
|
||||
|
||||
CFLAGS=-O2 -g -Wall -W `pkg-config --cflags librtlsdr`
|
||||
LIBS=`pkg-config --libs librtlsdr` -lpthread -lm
|
||||
LIBS=`pkg-config --libs librtlsdr` -lpthread -lm -lrt
|
||||
CC=gcc
|
||||
|
||||
|
||||
|
|
10
dump1090.c
10
dump1090.c
|
@ -507,6 +507,13 @@ static void display_stats(void) {
|
|||
printf("%d sample blocks processed\n", Modes.stat_blocks_processed);
|
||||
printf("%d sample blocks dropped\n", Modes.stat_blocks_dropped);
|
||||
|
||||
if (Modes.stat_blocks_processed > 0) {
|
||||
long cpu_millis = (long)Modes.stat_cputime.tv_sec*1000L + Modes.stat_cputime.tv_nsec/1000000L;
|
||||
long sample_millis = Modes.stat_blocks_processed * MODES_ASYNC_BUF_SAMPLES / (Modes.oversample ? 2400 : 2000);
|
||||
printf("%ld ms CPU time used to process %ld ms samples, %.1f%% load\n",
|
||||
cpu_millis, sample_millis, 100.0 * cpu_millis / sample_millis);
|
||||
}
|
||||
|
||||
printf("%d ModeA/C detected\n", Modes.stat_ModeAC);
|
||||
printf("%d Mode-S preambles with poor correlation\n", Modes.stat_preamble_no_correlation);
|
||||
printf("%d Mode-S preambles with noise in the quiet period\n", Modes.stat_preamble_not_quiet);
|
||||
|
@ -549,6 +556,9 @@ static void display_stats(void) {
|
|||
printf("%d total usable messages\n", Modes.stat_goodcrc + Modes.stat_ph_goodcrc + Modes.stat_fixed + Modes.stat_ph_fixed);
|
||||
fflush(stdout);
|
||||
|
||||
Modes.stat_cputime.tv_sec = 0;
|
||||
Modes.stat_cputime.tv_nsec = 0;
|
||||
|
||||
Modes.stat_blocks_processed =
|
||||
Modes.stat_blocks_dropped = 0;
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <time.h>
|
||||
#include "rtl-sdr.h"
|
||||
#include "anet.h"
|
||||
#else
|
||||
|
@ -387,6 +388,8 @@ struct { // Internal state
|
|||
|
||||
unsigned int stat_blocks_processed;
|
||||
unsigned int stat_blocks_dropped;
|
||||
|
||||
struct timespec stat_cputime;
|
||||
} Modes;
|
||||
|
||||
// The struct we use to store information about a decoded message.
|
||||
|
|
14
mode_s.c
14
mode_s.c
|
@ -2082,6 +2082,9 @@ void detectModeS_oversample(uint16_t *m, uint32_t mlen) {
|
|||
unsigned char msg[MODES_LONG_MSG_BYTES], *pMsg;
|
||||
uint32_t j;
|
||||
|
||||
struct timespec cpu_start_time, cpu_end_time;
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &cpu_start_time);
|
||||
|
||||
memset(&mm, 0, sizeof(mm));
|
||||
|
||||
for (j = 0; j < mlen; j++) {
|
||||
|
@ -2412,6 +2415,17 @@ void detectModeS_oversample(uint16_t *m, uint32_t mlen) {
|
|||
}
|
||||
}
|
||||
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &cpu_end_time);
|
||||
Modes.stat_cputime.tv_sec += (cpu_end_time.tv_sec - cpu_start_time.tv_sec);
|
||||
Modes.stat_cputime.tv_nsec += (cpu_end_time.tv_nsec - cpu_start_time.tv_nsec);
|
||||
if (Modes.stat_cputime.tv_nsec < 0) {
|
||||
Modes.stat_cputime.tv_nsec += 1000000000L;
|
||||
Modes.stat_cputime.tv_sec--;
|
||||
} else if (Modes.stat_cputime.tv_nsec > 1000000000L) {
|
||||
Modes.stat_cputime.tv_nsec -= 1000000000L;
|
||||
Modes.stat_cputime.tv_sec++;
|
||||
}
|
||||
|
||||
//Send any remaining partial raw buffers now
|
||||
if (Modes.rawOutUsed || Modes.beastOutUsed)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue