geopm  3.1.1.dev214+gba4f9f6d
GEOPM - Global Extensible Open Power Manager
Namespaces | Functions
StatsCollector.cpp File Reference
#include "StatsCollector.hpp"
#include "geopm_stats_collector.h"
#include <sstream>
#include <cmath>
#include <cstring>
#include "geopm/Exception.hpp"
#include "geopm/Helper.hpp"
#include "geopm/PlatformIO.hpp"
#include "geopm/PlatformTopo.hpp"
#include "geopm_time.h"
#include "RuntimeStats.hpp"
Include dependency graph for StatsCollector.cpp:

Namespaces

 geopm
 

Functions

int geopm_stats_collector_create (size_t num_requests, const struct geopm_request_s *requests, struct geopm_stats_collector_s **collector)
 Create a stats collector handle. More...
 
int geopm_stats_collector_update (struct geopm_stats_collector_s *collector)
 Update a stat collector with new values. More...
 
int geopm_stats_collector_update_count (const struct geopm_stats_collector_s *collector, size_t *update_count)
 Number of updates since last reset. More...
 
int geopm_stats_collector_report_yaml (const struct geopm_stats_collector_s *collector, size_t *max_report_size, char *report_yaml)
 Create a yaml report. More...
 
int geopm_stats_collector_report (const struct geopm_stats_collector_s *collector, size_t num_requests, geopm_report_s *report)
 
int geopm_stats_collector_reset (struct geopm_stats_collector_s *collector)
 Reset statistics. More...
 
int geopm_stats_collector_free (struct geopm_stats_collector_s *collector)
 Release resources associated with collector handle. More...
 

Function Documentation

◆ geopm_stats_collector_create()

int geopm_stats_collector_create ( size_t  num_requests,
const struct geopm_request_s requests,
struct geopm_stats_collector_s **  collector 
)

Create a stats collector handle.

Provide a list of PlatformIO signal requests and construct a stats collector object. The request list determine which statistics will be included in the generated report.

Parameters
[in]num_requestsNumber of requests in array pointed to by the request pointer
[in]requestsArray of PlatformIO signal requests that configures the report contents
[out]collectorHandle to the constructed StatsCollector object, must be de-allocated with geopm_stats_collector_free()
Returns
0 upon success, or error code upon failure

◆ geopm_stats_collector_free()

int geopm_stats_collector_free ( struct geopm_stats_collector_s *  collector)

Release resources associated with collector handle.

Parameters
[in]collectorHandle created with a call to geopm_stats_collector_create()
Returns
0 upon success, or error code upon failure

◆ geopm_stats_collector_report()

int geopm_stats_collector_report ( const struct geopm_stats_collector_s *  collector,
size_t  num_requests,
geopm_report_s report 
)

◆ geopm_stats_collector_report_yaml()

int geopm_stats_collector_report_yaml ( const struct geopm_stats_collector_s *  collector,
size_t *  max_report_size,
char *  report_yaml 
)

Create a yaml report.

Create a report that shows all statistics gathered by calls to geopm_stats_collector_update(). To determine the size of the report string, call with *max_report_size == 0 and report_yaml == NULL. In this case max_report_size will be updated with the required string length and zero is returned. Otherwise, if *max_report_size provided by the user is not sufficient, EINVAL is returned and the value of *max_report_size is set to the required size and report_yaml is unmodified.

Parameters
[in]collectorHandle created with a call to geopm_stats_collector_create()
[in,out]max_report_sizeSet to the length of the report_yaml string provided by the user, set to zero to query value. If too small, will be updated with required value.
[out]report_yamlGenerated report string allocated by the user, set to NULL to query max_report_size without error.
Returns
0 upon success, or error code upon failure

◆ geopm_stats_collector_reset()

int geopm_stats_collector_reset ( struct geopm_stats_collector_s *  collector)

Reset statistics.

Called by user to zero all statistics gathered. This may be called after a call to geopm_stats_collector_report_yaml() and before the next call to geopm_stats_collector_update() so that the next report that is generated is independent of the last.

Parameters
[in]collectorHandle created with a call to geopm_stats_collector_create()
Returns
0 upon success, or error code upon failure

◆ geopm_stats_collector_update()

int geopm_stats_collector_update ( struct geopm_stats_collector_s *  collector)

Update a stat collector with new values.

User is expected to call PlatformIO::read_batch() prior to calling this interface. The sampled values will be used to update the report statistics.

Parameters
[in]collectorHandle created with a call to geopm_stats_collector_create()
Returns
0 upon success, or error code upon failure

◆ geopm_stats_collector_update_count()

int geopm_stats_collector_update_count ( const struct geopm_stats_collector_s *  collector,
size_t *  update_count 
)

Number of updates since last reset.

Sets update_count to the number of times that the geopm_stats_collector_update() function has been called on the collector object since it was created, or since the last call to geopm_stats_collector_reset().

Parameters
[in]collectorHandle created with a call to geopm_stats_collector_create()
[out]update_countSet to the number of updates upon successful completion
Returns
0 upon success, or error code upon failure