You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.5 KiB
106 lines
2.5 KiB
// Copyright 2020 Siemens Digital Industries Software
|
|
// ==================================================
|
|
// Copyright 2015
|
|
// Siemens Product Lifecycle Management Software Inc.
|
|
// All Rights Reserved.
|
|
// ==================================================
|
|
// Copyright 2020 Siemens Digital Industries Software
|
|
|
|
/**
|
|
@file
|
|
|
|
Measures the CPU time, real time and the SQL call resources.
|
|
*/
|
|
|
|
#ifndef TEAMCENTER__RESOURCES_HXX
|
|
#define TEAMCENTER__RESOURCES_HXX
|
|
|
|
#include <fclasses/libfclasses_exports.h>
|
|
|
|
namespace Teamcenter
|
|
{
|
|
/**
|
|
Measures the CPU time, real time and the SQL call resources.
|
|
|
|
@code
|
|
Resouces resources;
|
|
resources.start(); // Clear resource accumulators and start timing
|
|
|
|
// Perform activity to be measured.
|
|
|
|
resources.stop(); // Stop timing and accumulate resources used
|
|
|
|
lprintf( "real_time=%08.6f cpu_time=%08.6f SQL_count=%d.\n",
|
|
resources.realTime(), resources.cpuTime(), resources.sqlCount() );
|
|
@endcode
|
|
|
|
Timing of an activity can be suspended by bracketing untimed steps with
|
|
stop/restart calls. The restart call resumes timing without clearing the
|
|
resource accumulators.
|
|
*/
|
|
class FCLASSES_API Resources
|
|
{
|
|
public:
|
|
/**
|
|
Constructor.
|
|
*/
|
|
Resources();
|
|
|
|
/**
|
|
Destructor.
|
|
*/
|
|
~Resources();
|
|
|
|
/**
|
|
Starts the resource measurement process and resets all existing usage measurements to 0.
|
|
<br/>The accumulated usage measurements are acquired as soon as the stop() method is called.
|
|
|
|
@note The start() method can be called several times.
|
|
*/
|
|
void start();
|
|
|
|
/**
|
|
Restarts timing without clearing the previous resource usage measurements.
|
|
<br/>The new usage measurements are acquired as soon as the stop() method is called.
|
|
|
|
@note The start() method can be called several times.
|
|
*/
|
|
void restart();
|
|
|
|
/**
|
|
Stops timing and computes the resource usage measurements.
|
|
*/
|
|
void stop();
|
|
|
|
/**
|
|
Retrieves the accumulated CPU time usage.
|
|
*/
|
|
double cpuTime();
|
|
|
|
/**
|
|
Retrieves the accumulated real time usage.
|
|
*/
|
|
double realTime();
|
|
|
|
/**
|
|
Retrieves the accumulated SQL call usage count.
|
|
*/
|
|
int sqlCount();
|
|
|
|
private:
|
|
Resources( const Resources& );
|
|
Resources& operator = ( const Resources& );
|
|
|
|
double m_cpu_start;
|
|
double m_cpu_usage;
|
|
|
|
double m_real_start;
|
|
double m_real_usage;
|
|
|
|
int m_sql_start;
|
|
int m_sql_usage;
|
|
};
|
|
}
|
|
#include <fclasses/libfclasses_undef.h>
|
|
#endif
|