Compile out timing debug prints

They can be compiled in if required
This commit is contained in:
Srivats P 2023-04-30 11:50:54 +05:30
parent 4ba98cc520
commit 8583299a1c
4 changed files with 39 additions and 10 deletions

29
common/debugdefs.h Normal file
View File

@ -0,0 +1,29 @@
/*
Copyright (C) 2023 Srivats P.
This file is part of "Ostinato"
This is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef _DEBUG_DEFS_H
#define _DEBUG_DEFS_H
#if 0
#define timingDebug(fmt, ...) qDebug("TIMING:" fmt, __VA_ARGS__)
#else
#define timingDebug(...)
#endif
#endif

View File

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "pcaprxstats.h" #include "pcaprxstats.h"
#include "pcapextra.h" #include "pcapextra.h"
#include "../common/debugdefs.h"
#include "../common/sign.h" #include "../common/sign.h"
#include "streamtiming.h" #include "streamtiming.h"
@ -124,7 +125,7 @@ _skip_filter:
uint ttagId, guid; uint ttagId, guid;
if (SignProtocol::packetTtagId(data, hdr->caplen, &ttagId, &guid)) { if (SignProtocol::packetTtagId(data, hdr->caplen, &ttagId, &guid)) {
timing_->recordRxTime(portId_, guid, ttagId, hdr->ts); timing_->recordRxTime(portId_, guid, ttagId, hdr->ts);
qDebug("XXXXX [%d RX] %ld:%ld ttag %u guid %u", portId_, timingDebug("[%d RX] %ld:%ld ttag %u guid %u", portId_,
hdr->ts.tv_sec, long(hdr->ts.tv_usec), ttagId, guid); hdr->ts.tv_sec, long(hdr->ts.tv_usec), ttagId, guid);
} }
if (guid != SignProtocol::kInvalidGuid) { if (guid != SignProtocol::kInvalidGuid) {

View File

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "pcaptxttagstats.h" #include "pcaptxttagstats.h"
#include "pcapextra.h" #include "pcapextra.h"
#include "../common/debugdefs.h"
#include "../common/sign.h" #include "../common/sign.h"
#include "streamtiming.h" #include "streamtiming.h"
@ -107,7 +108,7 @@ _skip_filter:
if (SignProtocol::packetTtagId(data, hdr->caplen, if (SignProtocol::packetTtagId(data, hdr->caplen,
&ttagId, &guid)) { &ttagId, &guid)) {
timing_->recordTxTime(portId_, guid, ttagId, hdr->ts); timing_->recordTxTime(portId_, guid, ttagId, hdr->ts);
qDebug("XXXXX [%d TX] %ld:%ld ttag %u guid %u", portId_, timingDebug("[%d TX] %ld:%ld ttag %u guid %u", portId_,
hdr->ts.tv_sec, long(hdr->ts.tv_usec), ttagId, guid); hdr->ts.tv_sec, long(hdr->ts.tv_usec), ttagId, guid);
} }
break; break;

View File

@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "streamtiming.h" #include "streamtiming.h"
#include "../common/debugdefs.h"
#include "timestamp.h" #include "timestamp.h"
#include <QCoreApplication> #include <QCoreApplication>
@ -122,9 +123,6 @@ quint64 StreamTiming::delay(uint portId, uint guid)
if (t.countDelays == 0) if (t.countDelays == 0)
return 0; return 0;
qDebug("XXXX [%u/%u] %lldns", portId, guid,
timespecToNsecs(t.sumDelays)/t.countDelays);
return timespecToNsecs(t.sumDelays)/t.countDelays; return timespecToNsecs(t.sumDelays)/t.countDelays;
} }
@ -178,12 +176,12 @@ int StreamTiming::processRecords()
count++; count++;
qDebug("XXXXX [%u/%u/%u] diff %ld.%09ld (%ld.%09ld - %ld.%09ld)", timingDebug("[%u/%u/%u] diff %ld.%09ld (%ld.%09ld - %ld.%09ld)",
i.value().portId, guid, i.key() & 0xFF, i.value().portId, guid, i.key() & 0xFF,
diff.tv_sec, diff.tv_nsec, diff.tv_sec, diff.tv_nsec,
rxTime.tv_sec, rxTime.tv_nsec, rxTime.tv_sec, rxTime.tv_nsec,
txTime.tv_sec, txTime.tv_nsec); txTime.tv_sec, txTime.tv_nsec);
qDebug("XXXXX %d:[%u/%u] total %ld.%09ld count %u", timingDebug("%d:[%u/%u] total %ld.%09ld count %u",
count, i.value().portId, guid, count, i.value().portId, guid,
guidTiming.sumDelays.tv_sec, guidTiming.sumDelays.tv_nsec, guidTiming.sumDelays.tv_sec, guidTiming.sumDelays.tv_nsec,
guidTiming.countDelays); guidTiming.countDelays);
@ -219,18 +217,18 @@ int StreamTiming::deleteStaleRecords()
struct timespec txTime = i.value().timeStamp; struct timespec txTime = i.value().timeStamp;
struct timespec diff; struct timespec diff;
timespecsub(&now, &txTime, &diff); timespecsub(&now, &txTime, &diff);
qDebug("XXXX gc diff %ld", diff.tv_sec); timingDebug("gc diff %ld", diff.tv_sec);
if (diff.tv_sec > 30) { if (diff.tv_sec > 30) {
i = txHash_.erase(i); i = txHash_.erase(i);
count++; count++;
qDebug("XXXX -%d", count);
} else { } else {
i++; i++;
} }
} }
qDebug("XXXX garbage collected %d stale tx timing records", count); if (count)
qDebug("Latency garbage collected %d stale tx timing records", count);
return count; return count;
} }