The watermark feature tells you how much of the available resources are actually consumed within Pia.
For example, with PiaTransport, the application can specify the size of the internal buffer. By using this watermark feature, you can know just how much of the internal buffer is used when the program runs. The application developer can then determine an appropriate size for the internal buffer and make more efficient use of memory.
To use the watermark feature, the application must explicitly create a singleton instance of WatermarkManager. The creation of the singleton must occur between the common::BeginSetup() and the common::EndSetup() functions.
nn::Result result;
result = nn::pia::common::BeginSetup(); PIA_ASSERT(result.IsSuccess()); // (Code to create other singletons.) // ......... // ......... // Creation of the WatermarkManager singleton. result = nn::pia::common::WatermarkManager::CreateInstance(); PIA_ASSERT(result.IsSuccess()); result = nn::pia::common::EndSetup(); PIA_ASSERT(result.IsSuccess()); |
Next, instructions are given to begin measurements.
nn::pia::common::WatermarkManager::GetInstance()->EnableAllWatermark();
|
Finally, after the application performs a series of processes, you get the target measurement results. The following code gets, as an example, measurement results for the PiaTransport send buffer.
nn::pia::common::WatermarkManager* pMgr = nn::pia::common::WatermarkManager::GetInstance();
nn::pia::common::Watermark* pMark = pMgr->GetWatermark(nn::pia::common::WatermarkManager::KEY_SENDTHREADSTREAM_BUFFER_NUM); if(pMark->GetUpdateCount() > 0) { PIA_SAMPLE_PRINT("Watermark: <%s> max: %lld, min: %lld, latest: %lld, Updates: %lld\n", pMark->GetName(), pMark->GetMaxValue(), pMark->GetMinValue(), pMark->GetLatestValue(), pMark->GetUpdateCount() ); } |
The following shows an example of results from this procedure. The number to the right of "max:" is the peak value of the send buffer usage amount. An application developer can then refer to these results to determine the appropriate send buffer size.
Watermark: <SendThreadStream buffer num> max: 6, min: 0, latest: 0, Updates: 14342
|
Values that can be obtained with the watermark feature are limited to the constants that are enumerated in the pattern KEY_XXX_XXX within the WatermarkManager class.