mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Performance : Use unordered_map
Use of unordered_map gives performance gain of 50% for lookup of addresses based on quantity name. Performance gain due to use of hash inside unordered_map.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RiuSummaryQuantityNameInfoProvider.h"
|
||||
#include <chrono>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -87,3 +88,31 @@ TEST( RiuSummaryQuantityNameInfoProvider, Test6x )
|
||||
EXPECT_TRUE( cat == RifEclipseSummaryAddress::SUMMARY_WELL );
|
||||
}
|
||||
}
|
||||
|
||||
TEST( DISABLED_RiuSummaryQuantityNameInfoProvider, PerformanceLookup )
|
||||
{
|
||||
std::vector<std::string> values;
|
||||
|
||||
values.emplace_back( "WOPT" );
|
||||
values.emplace_back( "WOPR" );
|
||||
values.emplace_back( "FOPT" );
|
||||
values.emplace_back( "FOPR" );
|
||||
values.emplace_back( "BHP" );
|
||||
values.emplace_back( "nothing" );
|
||||
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
const size_t iterationCount = 10000000;
|
||||
|
||||
for ( size_t i = 0; i < iterationCount; i++ )
|
||||
{
|
||||
for ( const auto& s : values )
|
||||
{
|
||||
auto category = RiuSummaryQuantityNameInfoProvider::instance()->categoryFromQuantityName( s );
|
||||
}
|
||||
}
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::duration<double> diff = end - start;
|
||||
std::cout << "RiuSummaryQuantityNameInfoProvider : Duration " << std::setw( 9 ) << diff.count() << " s\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user