Don't use the StopWatch for each job in production builds #5456

This accounted for more than 10% of the peak memory usage while only
providing value through the debugging log.
This commit is contained in:
Jocelyn Turcotte 2017-01-26 13:40:10 +01:00
parent 9db23d4df1
commit f1e9be4fa8
10 changed files with 18 additions and 6 deletions

View file

@ -41,7 +41,7 @@ endif (MEM_NULL_TESTS)
add_subdirectory(src)
if (UNIT_TESTING)
set(WITH_UNIT_TESTING ON)
set(WITH_TESTING ON)
find_package(CMocka)
if (CMOCKA_FOUND)

View file

@ -26,4 +26,4 @@
#cmakedefine HAVE___MINGW_ASPRINTF 1
#cmakedefine HAVE_ASPRINTF 1
#cmakedefine WITH_UNIT_TESTING 1
#cmakedefine WITH_TESTING 1

View file

@ -45,7 +45,7 @@
#define CSYNC_LOG_CATEGORY_NAME "csync.exclude"
#include "csync_log.h"
#ifndef WITH_UNIT_TESTING
#ifndef WITH_TESTING
static
#endif
int _csync_exclude_add(c_strlist_t **inList, const char *string) {

View file

@ -36,7 +36,7 @@ enum csync_exclude_type_e {
};
typedef enum csync_exclude_type_e CSYNC_EXCLUDE_TYPE;
#ifdef WITH_UNIT_TESTING
#ifdef WITH_TESTING
int OCSYNC_EXPORT _csync_exclude_add(c_strlist_t **inList, const char *string);
#endif

View file

@ -47,7 +47,7 @@ void ExcludedFiles::addExcludeFilePath(const QString& path)
_excludeFiles.insert(path);
}
#ifdef WITH_UNIT_TESTING
#ifdef WITH_TESTING
void ExcludedFiles::addExcludeExpr(const QString &expr)
{
_csync_exclude_add(_excludesPtr, expr.toLatin1().constData());

View file

@ -58,7 +58,7 @@ public:
const QString& basePath,
bool excludeHidden) const;
#ifdef WITH_UNIT_TESTING
#ifdef WITH_TESTING
void addExcludeExpr(const QString &expr);
#endif

View file

@ -224,7 +224,9 @@ void PropagateUploadFileCommon::slotComputeContentChecksum()
// change during the checksum calculation
_item->_modtime = FileSystem::getModTime(filePath);
#ifdef WITH_TESTING
_stopWatch.start();
#endif
QByteArray checksumType = contentChecksumType();
@ -251,8 +253,10 @@ void PropagateUploadFileCommon::slotComputeTransmissionChecksum(const QByteArray
_item->_contentChecksum = contentChecksum;
_item->_contentChecksumType = contentChecksumType;
#ifdef WITH_TESTING
_stopWatch.addLapTime(QLatin1String("ContentChecksum"));
_stopWatch.start();
#endif
// Reuse the content checksum as the transmission checksum if possible
const auto supportedTransmissionChecksums =
@ -299,7 +303,9 @@ void PropagateUploadFileCommon::slotStartUpload(const QByteArray& transmissionCh
done(SyncFileItem::SoftError, tr("File Removed"));
return;
}
#ifdef WITH_TESTING
_stopWatch.addLapTime(QLatin1String("TransmissionChecksum"));
#endif
time_t prevModtime = _item->_modtime; // the _item value was set in PropagateUploadFile::start()
// but a potential checksum calculation could have taken some time during which the file could

View file

@ -188,7 +188,9 @@ protected:
bool _deleteExisting;
// measure the performance of checksum calc and upload
#ifdef WITH_TESTING
Utility::StopWatch _stopWatch;
#endif
QByteArray _transmissionChecksum;
QByteArray _transmissionChecksumType;

View file

@ -483,6 +483,7 @@ void PropagateUploadFileNG::slotMoveJobFinished()
}
_item->_responseTimeStamp = job->responseTimestamp();
#ifdef WITH_TESTING
// performance logging
quint64 duration = _stopWatch.stop();
qDebug() << "*==* duration UPLOAD" << _item->_size
@ -491,6 +492,7 @@ void PropagateUploadFileNG::slotMoveJobFinished()
<< duration;
// The job might stay alive for the whole sync, release this tiny bit of memory.
_stopWatch.reset();
#endif
finalize();
}

View file

@ -339,6 +339,7 @@ void PropagateUploadFileV1::slotPutFinished()
done(SyncFileItem::SoftError, "Server does not support X-OC-MTime");
}
#ifdef WITH_TESTING
// performance logging
quint64 duration = _stopWatch.stop();
qDebug() << "*==* duration UPLOAD" << _item->_size
@ -347,6 +348,7 @@ void PropagateUploadFileV1::slotPutFinished()
<< duration;
// The job might stay alive for the whole sync, release this tiny bit of memory.
_stopWatch.reset();
#endif
finalize();
}