mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add Memory Report dialog
Compute how much memory is used for result/case/total. Show as text in dialog.
This commit is contained in:
parent
0c7a8ad2de
commit
df083a870a
@ -34,6 +34,10 @@
|
|||||||
#include "cafPdmUiPushButtonEditor.h"
|
#include "cafPdmUiPushButtonEditor.h"
|
||||||
#include "cafPdmUiTreeSelectionEditor.h"
|
#include "cafPdmUiTreeSelectionEditor.h"
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@ -55,6 +59,9 @@ RiaMemoryCleanup::RiaMemoryCleanup()
|
|||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault( &m_performDelete, "ClearSelectedData", "" );
|
CAF_PDM_InitFieldNoDefault( &m_performDelete, "ClearSelectedData", "" );
|
||||||
caf::PdmUiPushButtonEditor::configureEditorForField( &m_performDelete );
|
caf::PdmUiPushButtonEditor::configureEditorForField( &m_performDelete );
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault( &m_showMemoryReport, "ShowMemoryReport", "" );
|
||||||
|
caf::PdmUiPushButtonEditor::configureEditorForField( &m_showMemoryReport );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -107,6 +114,38 @@ void RiaMemoryCleanup::clearSelectedResultsFromMemory()
|
|||||||
m_geomResultAddresses.clear();
|
m_geomResultAddresses.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
class TextDialog : public QDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextDialog( const QString& text, QWidget* parent = nullptr )
|
||||||
|
: QDialog( parent )
|
||||||
|
{
|
||||||
|
auto textWidget = new QTextEdit( "", this );
|
||||||
|
textWidget->setPlainText( text );
|
||||||
|
auto layout = new QVBoxLayout( this );
|
||||||
|
layout->addWidget( textWidget );
|
||||||
|
setLayout( layout );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiaMemoryCleanup::showMemoryReport()
|
||||||
|
{
|
||||||
|
auto [summary, details] = createMemoryReport();
|
||||||
|
|
||||||
|
QString allText = summary + "\n\n" + details;
|
||||||
|
|
||||||
|
auto dialog = new TextDialog( allText );
|
||||||
|
dialog->setWindowTitle( "Memory Report" );
|
||||||
|
dialog->setMinimumSize( 800, 600 );
|
||||||
|
dialog->show();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -204,6 +243,12 @@ void RiaMemoryCleanup::fieldChangedByUi( const caf::PdmFieldHandle* changedField
|
|||||||
m_resultsToDelete.uiCapability()->updateConnectedEditors();
|
m_resultsToDelete.uiCapability()->updateConnectedEditors();
|
||||||
m_performDelete = false;
|
m_performDelete = false;
|
||||||
}
|
}
|
||||||
|
else if ( changedField == &m_showMemoryReport )
|
||||||
|
{
|
||||||
|
m_showMemoryReport = false;
|
||||||
|
|
||||||
|
showMemoryReport();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -310,10 +355,70 @@ void RiaMemoryCleanup::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
|||||||
{
|
{
|
||||||
if ( field == &m_performDelete )
|
if ( field == &m_performDelete )
|
||||||
{
|
{
|
||||||
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
||||||
if ( attrib )
|
if ( attrib )
|
||||||
{
|
{
|
||||||
attrib->m_buttonText = "Clear Checked Data From Memory";
|
attrib->m_buttonText = "Clear Checked Data From Memory";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( field == &m_showMemoryReport )
|
||||||
|
{
|
||||||
|
auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
||||||
|
if ( attrib )
|
||||||
|
{
|
||||||
|
attrib->m_buttonText = "Show Memory Report";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::pair<QString, QString> RiaMemoryCleanup::createMemoryReport()
|
||||||
|
{
|
||||||
|
QString details;
|
||||||
|
|
||||||
|
auto allCases = RimProject::current()->allGridCases();
|
||||||
|
|
||||||
|
size_t totalMemory = 0;
|
||||||
|
for ( auto gridCase : allCases )
|
||||||
|
{
|
||||||
|
if ( auto eclipseCase = dynamic_cast<RimEclipseCase*>( gridCase ) )
|
||||||
|
{
|
||||||
|
RigCaseCellResultsData* caseData = eclipseCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
||||||
|
if ( caseData )
|
||||||
|
{
|
||||||
|
size_t totalMemoryForCase = 0;
|
||||||
|
QString caseReport;
|
||||||
|
|
||||||
|
auto memoryUse = caseData->resultValueCount();
|
||||||
|
for ( const auto& [name, valueCount] : memoryUse )
|
||||||
|
{
|
||||||
|
if ( valueCount > 0 )
|
||||||
|
{
|
||||||
|
size_t memory = valueCount * sizeof( double );
|
||||||
|
totalMemoryForCase += memory;
|
||||||
|
|
||||||
|
caseReport += QString( " %1 MB\tValue count %2, %3\n" )
|
||||||
|
.arg( memory / 1024.0 / 1024.0, 0, 'f', 2 )
|
||||||
|
.arg( valueCount )
|
||||||
|
.arg( QString::fromStdString( name ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
totalMemory += totalMemoryForCase;
|
||||||
|
|
||||||
|
if ( totalMemoryForCase > 0 )
|
||||||
|
{
|
||||||
|
details +=
|
||||||
|
QString( "%1 - %2 MB\n" ).arg( eclipseCase->caseUserDescription() ).arg( totalMemoryForCase / 1024.0 / 1024.0, 0, 'f', 2 );
|
||||||
|
|
||||||
|
details += caseReport;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString summary = QString( "Total memory used: %1 MB\n\n" ).arg( totalMemory / 1024.0 / 1024.0, 0, 'f', 2 );
|
||||||
|
return std::make_pair( summary, details );
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ public:
|
|||||||
void setPropertiesFromView( Rim3dView* view );
|
void setPropertiesFromView( Rim3dView* view );
|
||||||
void clearSelectedResultsFromMemory();
|
void clearSelectedResultsFromMemory();
|
||||||
|
|
||||||
|
static void showMemoryReport();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||||
|
|
||||||
@ -52,10 +54,13 @@ private:
|
|||||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||||
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
||||||
|
|
||||||
|
static std::pair<QString, QString> createMemoryReport();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmPtrField<RimCase*> m_case;
|
caf::PdmPtrField<RimCase*> m_case;
|
||||||
caf::PdmField<std::vector<size_t>> m_resultsToDelete;
|
caf::PdmField<std::vector<size_t>> m_resultsToDelete;
|
||||||
std::vector<RigFemResultAddress> m_geomResultAddresses;
|
std::vector<RigFemResultAddress> m_geomResultAddresses;
|
||||||
std::vector<RigEclipseResultAddress> m_eclipseResultAddresses;
|
std::vector<RigEclipseResultAddress> m_eclipseResultAddresses;
|
||||||
caf::PdmField<bool> m_performDelete;
|
caf::PdmField<bool> m_performDelete;
|
||||||
|
caf::PdmField<bool> m_showMemoryReport;
|
||||||
};
|
};
|
||||||
|
@ -20,6 +20,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicShowClassNamesFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicShowClassNamesFeature.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicOpenInTextEditorFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicOpenInTextEditorFeature.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicShowMemoryReportFeature.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SOURCE_GROUP_SOURCE_FILES
|
set(SOURCE_GROUP_SOURCE_FILES
|
||||||
@ -44,6 +45,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicShowClassNamesFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicShowClassNamesFeature.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicOpenInTextEditorFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicOpenInTextEditorFeature.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicShowMemoryReportFeature.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2024 Equinor ASA
|
||||||
|
//
|
||||||
|
// ResInsight 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.
|
||||||
|
//
|
||||||
|
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "RicShowMemoryReportFeature.h"
|
||||||
|
|
||||||
|
#include "RiaMemoryCleanup.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT( RicShowMemoryReportFeature, "RicShowMemoryReportFeature" );
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicShowMemoryReportFeature::onActionTriggered( bool isChecked )
|
||||||
|
{
|
||||||
|
RiaMemoryCleanup::showMemoryReport();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicShowMemoryReportFeature::setupActionLook( QAction* actionToSetup )
|
||||||
|
{
|
||||||
|
actionToSetup->setText( "Memory Report" );
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2024 Equinor ASA
|
||||||
|
//
|
||||||
|
// ResInsight 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.
|
||||||
|
//
|
||||||
|
// ResInsight 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 at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicShowMemoryReportFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void onActionTriggered( bool isChecked ) override;
|
||||||
|
void setupActionLook( QAction* actionToSetup ) override;
|
||||||
|
};
|
@ -216,6 +216,24 @@ void RigCaseCellResultsData::mobileVolumeWeightedMean( const RigEclipseResultAdd
|
|||||||
statistics( resVarAddr )->mobileVolumeWeightedMean( timeStepIndex, meanValue );
|
statistics( resVarAddr )->mobileVolumeWeightedMean( timeStepIndex, meanValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::map<std::string, size_t> RigCaseCellResultsData::resultValueCount() const
|
||||||
|
{
|
||||||
|
std::map<std::string, size_t> memoryUse;
|
||||||
|
|
||||||
|
for ( size_t i = 0; i < m_cellScalarResults.size(); i++ )
|
||||||
|
{
|
||||||
|
if ( allocatedValueCount( i ) > 0 )
|
||||||
|
{
|
||||||
|
memoryUse[m_resultInfos[i].resultName().toStdString()] = allocatedValueCount( i );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return memoryUse;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -2838,22 +2856,25 @@ RigAllanDiagramData* RigCaseCellResultsData::allanDiagramData()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RigCaseCellResultsData::isDataPresent( size_t scalarResultIndex ) const
|
bool RigCaseCellResultsData::isDataPresent( size_t scalarResultIndex ) const
|
||||||
{
|
{
|
||||||
if ( scalarResultIndex >= resultCount() )
|
return allocatedValueCount( scalarResultIndex ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
size_t RigCaseCellResultsData::allocatedValueCount( size_t scalarResultIndex ) const
|
||||||
|
{
|
||||||
|
if ( scalarResultIndex >= resultCount() ) return 0;
|
||||||
|
|
||||||
|
const std::vector<std::vector<double>>& valuesAllTimeSteps = m_cellScalarResults[scalarResultIndex];
|
||||||
|
|
||||||
|
size_t valueCount = 0;
|
||||||
|
for ( const auto& values : valuesAllTimeSteps )
|
||||||
{
|
{
|
||||||
return false;
|
valueCount += values.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::vector<double>>& data = m_cellScalarResults[scalarResultIndex];
|
return valueCount;
|
||||||
|
|
||||||
for ( size_t tsIdx = 0; tsIdx < data.size(); ++tsIdx )
|
|
||||||
{
|
|
||||||
if ( !data[tsIdx].empty() )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -99,6 +99,9 @@ public:
|
|||||||
void mobileVolumeWeightedMean( const RigEclipseResultAddress& resVarAddr, double& meanValue );
|
void mobileVolumeWeightedMean( const RigEclipseResultAddress& resVarAddr, double& meanValue );
|
||||||
void mobileVolumeWeightedMean( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& meanValue );
|
void mobileVolumeWeightedMean( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& meanValue );
|
||||||
|
|
||||||
|
// Return the number of double values allocated for each result
|
||||||
|
std::map<std::string, size_t> resultValueCount() const;
|
||||||
|
|
||||||
// Access meta-information about the results
|
// Access meta-information about the results
|
||||||
|
|
||||||
size_t timeStepCount( const RigEclipseResultAddress& resVarAddr ) const;
|
size_t timeStepCount( const RigEclipseResultAddress& resVarAddr ) const;
|
||||||
@ -199,7 +202,8 @@ private:
|
|||||||
void computeFaultDistance();
|
void computeFaultDistance();
|
||||||
void computeNncsCells();
|
void computeNncsCells();
|
||||||
|
|
||||||
bool isDataPresent( size_t scalarResultIndex ) const;
|
bool isDataPresent( size_t scalarResultIndex ) const;
|
||||||
|
size_t allocatedValueCount( size_t scalarResultIndex ) const;
|
||||||
|
|
||||||
void assignValuesToTemporaryLgrs( const QString& resultName, std::vector<double>& values );
|
void assignValuesToTemporaryLgrs( const QString& resultName, std::vector<double>& values );
|
||||||
|
|
||||||
|
@ -672,6 +672,7 @@ void RiuMainWindow::createToolBars()
|
|||||||
toolbar->addAction( cmdFeatureMgr->action( "RicRunCommandFileFeature" ) );
|
toolbar->addAction( cmdFeatureMgr->action( "RicRunCommandFileFeature" ) );
|
||||||
toolbar->addAction( cmdFeatureMgr->action( "RicExecuteLastUsedScriptFeature" ) );
|
toolbar->addAction( cmdFeatureMgr->action( "RicExecuteLastUsedScriptFeature" ) );
|
||||||
toolbar->addAction( cmdFeatureMgr->action( "RicExportCompletionsForVisibleWellPathsFeature" ) );
|
toolbar->addAction( cmdFeatureMgr->action( "RicExportCompletionsForVisibleWellPathsFeature" ) );
|
||||||
|
toolbar->addAction( cmdFeatureMgr->action( "RicShowMemoryReportFeature" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create animation toolbar
|
// Create animation toolbar
|
||||||
|
Loading…
Reference in New Issue
Block a user