HEBench
hebench::TestHarness::PartialBenchmark Class Referenceabstract

Base class for benchmarks. More...

#include <hebench_ibenchmark.h>

Inheritance diagram for hebench::TestHarness::PartialBenchmark:
Collaboration diagram for hebench::TestHarness::PartialBenchmark:

Classes

class  FriendPrivateKey
 

Public Types

typedef std::shared_ptr< PartialBenchmarkPtr
 
- Public Types inherited from hebench::TestHarness::IBenchmark
typedef std::shared_ptr< IBenchmarkPtr
 

Public Member Functions

 ~PartialBenchmark () override
 
std::weak_ptr< EnginegetEngine () const override
 
const hebench::APIBridge::Handlehandle () const override
 
virtual std::uint32_t getEventIDStart () const
 An ID to identify the first event during the benchmark run. More...
 
std::uint32_t getEventIDNext ()
 Returns the next available event ID. More...
 
virtual void init ()=0
 Initializes the partial benchmark members. More...
 
void initBackend (hebench::Utilities::TimingReportEx &out_report, const FriendPrivateKey &)
 Initializes backend benchmark. More...
 
virtual void postInit ()
 Called automatically during initialization after the backend has been initialized. More...
 
void checkInitializationState (const FriendPrivateKey &) const
 Used to check that initialization steps have been completed successfully. More...
 
- Public Member Functions inherited from hebench::TestHarness::IBenchmark
virtual ~IBenchmark ()=default
 
virtual bool run (hebench::Utilities::TimingReportEx &out_report, RunConfig &config)=0
 Executes the benchmark operations. More...
 

Protected Member Functions

const BenchmarkDescription::BackendgetBackendDescription () const
 Allows read-only access to this benchmark backend description. More...
 
const BenchmarkDescription::ConfigurationgetBenchmarkConfiguration () const
 Allows read-only access to this benchmark configuration. More...
 
const BenchmarkDescription::DescriptiongetDescription () const
 Allows read-only access to this benchmark text description. More...
 
 PartialBenchmark (std::shared_ptr< Engine > p_engine, const IBenchmarkDescriptor::DescriptionToken &description_token)
 
void validateRetCode (hebench::APIBridge::ErrorCode err_code, bool last_error=true) const
 Validates whether the specified HEBench API return code represents a success or error. More...
 
- Protected Member Functions inherited from hebench::TestHarness::IBenchmark
 IBenchmark ()=default
 

Detailed Description

Base class for benchmarks.

This class offers common implementations to trivial methods declared by interface IBenchmark.

To extend this class and create workloads, it is easier to extend directly from the workload category benchmark classes BenchmarkLatency, BenchmarkOffline, etc. If more control or specific processing other than the generic category execution is needed, extending from this class offers more flexibility.

Definition at line 499 of file hebench_ibenchmark.h.

Member Typedef Documentation

◆ Ptr

Definition at line 517 of file hebench_ibenchmark.h.

Constructor & Destructor Documentation

◆ ~PartialBenchmark()

hebench::TestHarness::PartialBenchmark::~PartialBenchmark ( )
override

Definition at line 619 of file hebench_ibenchmark.cpp.

◆ PartialBenchmark()

hebench::TestHarness::PartialBenchmark::PartialBenchmark ( std::shared_ptr< Engine p_engine,
const IBenchmarkDescriptor::DescriptionToken description_token 
)
protected

Definition at line 602 of file hebench_ibenchmark.cpp.

Member Function Documentation

◆ checkInitializationState()

void hebench::TestHarness::PartialBenchmark::checkInitializationState ( const FriendPrivateKey ) const

Used to check that initialization steps have been completed successfully.

Exceptions
std::runtime_errorif initialization of PartialBenchmark is incomplete.

During benchmark creation and initialization the following methods are called in order automatically by the framework:

(constructor)
virtual void init()=0
Initializes the partial benchmark members.
virtual void postInit()
Called automatically during initialization after the backend has been initialized.
void checkInitializationState(const FriendPrivateKey &) const
Used to check that initialization steps have been completed successfully.
void initBackend(hebench::Utilities::TimingReportEx &out_report, const FriendPrivateKey &)
Initializes backend benchmark.

If any existing default base implementation of these methods provided by PartialBenchmark has not been called, then this method will fail and the exception will be thrown.

See also
init(), initBackend(), postInit()

Definition at line 670 of file hebench_ibenchmark.cpp.

◆ getBackendDescription()

const BenchmarkDescription::Backend& hebench::TestHarness::PartialBenchmark::getBackendDescription ( ) const
inlineprotected

Allows read-only access to this benchmark backend description.

Definition at line 608 of file hebench_ibenchmark.h.

◆ getBenchmarkConfiguration()

const BenchmarkDescription::Configuration& hebench::TestHarness::PartialBenchmark::getBenchmarkConfiguration ( ) const
inlineprotected

Allows read-only access to this benchmark configuration.

Definition at line 612 of file hebench_ibenchmark.h.

◆ getDescription()

const BenchmarkDescription::Description& hebench::TestHarness::PartialBenchmark::getDescription ( ) const
inlineprotected

Allows read-only access to this benchmark text description.

Definition at line 616 of file hebench_ibenchmark.h.

◆ getEngine()

std::weak_ptr<Engine> hebench::TestHarness::PartialBenchmark::getEngine ( ) const
inlineoverridevirtual

Implements hebench::TestHarness::IBenchmark.

Definition at line 521 of file hebench_ibenchmark.h.

◆ getEventIDNext()

std::uint32_t hebench::TestHarness::PartialBenchmark::getEventIDNext ( )
inline

Returns the next available event ID.

Returns
An integer representing the next available event ID that has not been returned before.

Next available event ID starts from getEventIDStart() and increments by one on every call to this method. This ensures unique event IDs for an object of this class.

Definition at line 543 of file hebench_ibenchmark.h.

◆ getEventIDStart()

virtual std::uint32_t hebench::TestHarness::PartialBenchmark::getEventIDStart ( ) const
inlinevirtual

◆ handle()

const hebench::APIBridge::Handle& hebench::TestHarness::PartialBenchmark::handle ( ) const
inlineoverridevirtual

Implements hebench::TestHarness::IBenchmark.

Definition at line 522 of file hebench_ibenchmark.h.

◆ init()

virtual void hebench::TestHarness::PartialBenchmark::init ( )
pure virtual

◆ initBackend()

void hebench::TestHarness::PartialBenchmark::initBackend ( hebench::Utilities::TimingReportEx out_report,
const FriendPrivateKey  
)

Initializes backend benchmark.

HEBench API calls are performed here in order to initialize the benchmark corresponding to the description token used during construction.

Definition at line 640 of file hebench_ibenchmark.cpp.

◆ postInit()

void hebench::TestHarness::PartialBenchmark::postInit ( )
virtual

Called automatically during initialization after the backend has been initialized.

This method allows clients to perform polymorphic initialization outside of the class constructor after the backend benchmark has been initialized, if needed.

Derived classes MUST call this base implementation as first step when overriding, otherwise, checkInitializationState() will throw exceptions.

This method is called automatically during creation and initialization of the benchmark.

See also
checkInitializationState()

Definition at line 635 of file hebench_ibenchmark.cpp.

◆ validateRetCode()

void hebench::TestHarness::PartialBenchmark::validateRetCode ( hebench::APIBridge::ErrorCode  err_code,
bool  last_error = true 
) const
protected

Validates whether the specified HEBench API return code represents a success or error.

Parameters
[in]err_codeError code to validate.
[in]last_errorSpecifies if this is the latest error to occur.
Exceptions
std::runtime_errorif err_code represents an error.

If err_code represents success, this method returns immediately. Otherwise, a std::runtime_error exception is thrown with the error description and extra information as retrieved from the backend if requested by setting last_error to true.

Definition at line 676 of file hebench_ibenchmark.cpp.


The documentation for this class was generated from the following files: