]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Don't use the StopWatch for each job in production builds #5456
authorJocelyn Turcotte <jturcotte@woboq.com>
Thu, 26 Jan 2017 12:40:10 +0000 (13:40 +0100)
committerJocelyn Turcotte <jturcotte@woboq.com>
Thu, 26 Jan 2017 16:13:54 +0000 (17:13 +0100)
This accounted for more than 10% of the peak memory usage while only
providing value through the debugging log.

csync/CMakeLists.txt
csync/config_csync.h.cmake
csync/src/csync_exclude.c
csync/src/csync_exclude.h
src/libsync/excludedfiles.cpp
src/libsync/excludedfiles.h
src/libsync/propagateupload.cpp
src/libsync/propagateupload.h
src/libsync/propagateuploadng.cpp
src/libsync/propagateuploadv1.cpp

index d34926c59b3af6c385acebaf934f3677bb863674..808349ba58c7dc1e42f3d1233c2b5a4d20ce33cf 100644 (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)
index c42eb10450c6910b6e0a2c761e7f6c2f5d9f52c5..155329bbd753199117e83a27d78833bc336679b5 100644 (file)
@@ -26,4 +26,4 @@
 #cmakedefine HAVE___MINGW_ASPRINTF 1
 #cmakedefine HAVE_ASPRINTF 1
 
-#cmakedefine WITH_UNIT_TESTING 1
+#cmakedefine WITH_TESTING 1
index bf636c3de0b7ca24fac75ab85fb09d53646f4417..e125b33462539e14d532eeee0193189c67887ca6 100644 (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) {
index f9f26547ddd0053e833e418cbe01f12e85702797..ae49bbd8d1730cb11e14f06400f8c64c48446c3a 100644 (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
 
index 80e459f101969c450fa2b6f28a8d7e6b9c96d71c..d9793ce0f06cec1737001c12bdeab8c1ddad79e0 100644 (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());
index 441aa29ae7a8a5e87b713848b7675fd3cb1c2a0f..97e3a98da37aef489ddc2a0cc1ccc1c8b141f3e0 100644 (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
 
index cd0b4a2328b18f3b808e84e87d04a0cebf95c3f8..b3b737a6b7b839ca51cb2305326bc5157a835500 100644 (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
index 3638acdbbfc1f0de92f8b62bc7d171ec2c71ee45..db70b566c621b377b117f5db0bfbaa1b486c97dc 100644 (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;
index 459d9991b3e6df8aacb813f3573db0e99c51f938..5d637d467f53e4453599bf9d307e35a22fdde4c8 100644 (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();
 }
 
index 21778a7d3de2c608338210531ac72c23282e763c..081a0dc4fc1a94dacc4ecdc573d4e105fb4cdf39 100644 (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();
 }