# HG changeset patch # User Alain Mazy # Date 1753175684 -7200 # Node ID 66c421fc2fbf25afa9892eaab5b31dfc5ca5c99b # Parent d8114860cba4f2f2b1cf60fb3bcb2252e198a982 EnablePerformanceLogs diff -r d8114860cba4 -r 66c421fc2fbf NEWS --- a/NEWS Fri Jun 13 15:30:50 2025 +0200 +++ b/NEWS Tue Jul 22 11:14:44 2025 +0200 @@ -5,6 +5,9 @@ files from the storage when answering to a WADO-RS query. A value > 1 is meaningful only if the storage is a distributed network storage (e.g object storage plugin). A value of 0 means reading and writing are performed in sequence (default behaviour). +* New configuration "EnablePerformanceLogs" to display performance logs. Currently + only showing the time required to execute a WADO-RS query. For example: + WADO-RS: elapsed: 26106623 us, rate: 14.86 files/s, 155.23Mbps Version 1.20 (2025-05-12) diff -r d8114860cba4 -r 66c421fc2fbf Plugin/Configuration.cpp --- a/Plugin/Configuration.cpp Fri Jun 13 15:30:50 2025 +0200 +++ b/Plugin/Configuration.cpp Tue Jul 22 11:14:44 2025 +0200 @@ -696,6 +696,11 @@ return GetUnsignedIntegerValue("WadoRsLoaderThreadsCount", 0); } + bool IsPerformanceLogsEnabled() + { + return GetBooleanValue("EnablePerformanceLogs", false); + } + MetadataMode GetMetadataMode(Orthanc::ResourceType level) { static const std::string FULL = "Full"; diff -r d8114860cba4 -r 66c421fc2fbf Plugin/Configuration.h --- a/Plugin/Configuration.h Fri Jun 13 15:30:50 2025 +0200 +++ b/Plugin/Configuration.h Tue Jul 22 11:14:44 2025 +0200 @@ -146,5 +146,7 @@ bool IsMetadataCacheEnabled(); bool IsReadOnly(); + + bool IsPerformanceLogsEnabled(); } } diff -r d8114860cba4 -r 66c421fc2fbf Plugin/WadoRs.cpp --- a/Plugin/WadoRs.cpp Fri Jun 13 15:30:50 2025 +0200 +++ b/Plugin/WadoRs.cpp Tue Jul 22 11:14:44 2025 +0200 @@ -595,6 +595,10 @@ bool transcode, Orthanc::DicomTransferSyntax targetSyntax /* only if transcoding */) { + Orthanc::Toolbox::ElapsedTimer perfTimer; + size_t perfTotalSizeInBytes = 0; + size_t perfTotalFilesCount = 0; + if (level != Orthanc::ResourceType_Study && level != Orthanc::ResourceType_Series && level != Orthanc::ResourceType_Instance) @@ -723,6 +727,8 @@ loader->PrepareDicom(instances[i]["ID"].asString(), transcodeThisInstance); } + perfTotalFilesCount = instances.size(); + for (Json::Value::ArrayIndex i = 0; i < instances.size(); i++) { std::unique_ptr dicom(loader->GetNextDicom()); @@ -735,12 +741,20 @@ { throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } + perfTotalSizeInBytes += dicom->GetSize(); } else { LOG(WARNING) << "Failed to load an instance"; } } + + if (OrthancPlugins::Configuration::IsPerformanceLogsEnabled()) + { + uint64_t elapsedMicrosends = perfTimer.GetElapsedMicroseconds(); + float filesPerSeconds = float(perfTotalFilesCount) / (float(elapsedMicrosends) / 1000000.0f); + LOG(INFO) << "WADO-RS: elapsed: " << perfTimer.GetElapsedMicroseconds() << " us, rate: " << std::fixed << std::setprecision(2) << filesPerSeconds << " files/s, " << Orthanc::Toolbox::GetHumanTransferSpeed(false, perfTotalSizeInBytes, elapsedMicrosends * 1000); + } }