4.5.2 Meter Reference
A meter is an device that produces measurement samples.
Currently, the only meters provide by the library are chronometers
(see Chronometer Reference.)
- C Data Type: micro_benchmark_meter_data {
void *
ptr, const char *
name, micro_benchmark_stats_sample_type
sample_type, micro_benchmark_stats_meter_sample
min_resolution, micro_benchmark_stats_meter_sample
max_resolution } ¶
-
Data of a meter implementation.
ptr
is the instance data that is provided to the meter
functions. sample_type
represents the active union field from
the samples produced by the meter, as well as min_resolution
and max_resolution
fields.
- C Function Type: micro_benchmark_meter_init_fun ¶
-
Function to initialize a meter instance. Its prototype is void
(*) (micro_benchmark_meter_data *, const void *)
.
- C Function Type: micro_benchmark_meter_cleanup_fun ¶
-
Function to release a meter instance. Its prototype is void (*)
(const micro_benchmark_meter_data *)
.
- C Function Type: micro_benchmark_meter_start_fun ¶
-
Start the measuring process of a meter instance. Its prototype is
void (*) (void *)
.
- C Function Type: micro_benchmark_meter_stop_fun ¶
-
Stop the measuring process of a meter instance. Its prototype is
void (*) (void *)
.
- C Function Type: micro_benchmark_meter_restart_fun ¶
-
Restart the measuring process of a meter instance. Its prototype is
void (*) (void *)
.
- C Function Type: micro_benchmark_meter_get_sample_fun ¶
-
Extract the measure performed by the meter. Its prototype is
micro_benchmark_stats_meter_sample (*) (void *)
.
- C Data Type: micro_benchmark_meter_definition {
micro_benchmark_meter_data
data, micro_benchmark_meter_init_fun
init, micro_benchmark_meter_cleanup_fun
cleanup, micro_benchmark_meter_start_fun
start, micro_benchmark_meter_stop_fun
stop, micro_benchmark_meter_restart_fun
restart, micro_benchmark_meter_get_sample_fun
get_sample } ¶
-
Meter definition.
- C Data Type: micro_benchmark_meter ¶
-
Pointer to a constant micro_benchmark_meter_definition object.
- C Meter Function: void micro_benchmark_stats_meter_init (micro_benchmark_meter_definition *meter) ¶
-
Preconditions:
- meter points to a valid object.
- meter->init points to a valid function.
- The value meter is not valid. This means one of the following
conditions:
- No value equivalent to meter has been provided as a parameter to
micro_benchmark_stats_meter_init
or
micro_benchmark_stats_meter_init_with_data
.
- Each call to
micro_benchmark_stats_meter_init
or
micro_benchmark_stats_meter_init_with_data
with a value
equivalent to meter as its parameter has been followed by a call
to micro_benchmark_stats_meter_cleanup
with a value equivalent
to meter as its parameter.
Effects:
- Call
meter->init (meter->data, NULL)
.
Postconditions:
- The value meter is valid.
- C Meter Function: void micro_benchmark_stats_meter_init_with_data (micro_benchmark_meter_definition *meter, const void *extra_data) ¶
-
Preconditions:
- meter points to a valid object.
- meter->init points to a valid function.
- The value meter is not valid. This means one of the following
conditions:
- The value meter has not been provided as a parameter to
micro_benchmark_stats_meter_init
or
micro_benchmark_stats_meter_init_with_data
.
- Each call to
micro_benchmark_stats_meter_init
or
micro_benchmark_stats_meter_init_with_data
with the value of
meter as its parameter has been followed by a call to
micro_benchmark_stats_meter_cleanup
with the value of
meter as its parameter.
Effects:
- Call
meter->init (meter->data, extra_data)
.
Postconditions:
- The value meter is valid.
- C Meter Function: void micro_benchmark_stats_meter_cleanup (micro_benchmark_meter meter) ¶
-
Preconditions:
- meter points to a valid object.
- meter->cleanup points to a valid function.
- The value meter is valid.
Effects:
- Call
meter->cleanup
.
Postconditions:
- The value meter is not valid.
- C Meter Function: void micro_benchmark_stats_meter_start (micro_benchmark_meter meter) ¶
-
Preconditions:
- meter points to a valid object.
- meter->start points to a valid function.
- The value meter is valid.
- meter is not measuring.
Effects:
- Call
meter->start
.
Postconditions:
- meter is running.
- meter is measuring.
- The measurements performed by meter take this call as its
starting point.
- C Meter Function: void micro_benchmark_stats_meter_stop (micro_benchmark_meter meter) ¶
-
Preconditions:
- meter points to a valid object.
- meter->stop points to a valid function.
- The value meter is valid.
- meter is running.
- meter is measuring.
Effects:
- Call
meter->stop
.
Postconditions:
- meter is not measuring.
- The measurements performed by meter take this call as its end
point.
- C Meter Function: void micro_benchmark_stats_meter_restart (micro_benchmark_meter meter) ¶
-
Preconditions:
- meter points to a valid object.
- meter->restart points to a valid function.
- The value meter is valid.
- meter is running.
- meter is not measuring.
Effects:
- Call
meter->restart
.
Postconditions:
- meter is measuring.
- The measurements performed by meter take this call as another
starting point.
- C Meter Function: micro_benchmark_stats_meter_sample micro_benchmark_stats_meter_get_sample (micro_benchmark_meter meter) ¶
-
Preconditions:
- meter points to a valid object.
- The value meter is valid.
- meter is running.
- meter is not measuring.
Effects:
- Call
meter->get_sample
.
Postconditions:
- The returned value contains the accumulated measurement performed by
the value meter.
- The accumulated measurement of meter is reset to zero its zero
point—equivalent to a call to
micro_benchmark_meter_start
.
- C Meter Function: const char * micro_benchmark_stats_meter_get_name (micro_benchmark_meter meter) ¶
-
Preconditions:
- meter points to a valid object.
- The value meter is valid.
Effects:
- None.
Postconditions:
- The returned value is meter->data.name;
- C Meter Function: micro_benchmark_stats_sample_type micro_benchmark_stats_meter_get_sample_type (micro_benchmark_meter meter) ¶
-
Preconditions:
- meter points to a valid object.
- The value meter is valid.
Effects:
- None.
Postconditions:
- The returned value is meter->data.sample_type;
- C Meter Function: micro_benchmark_stats_meter_sample micro_benchmark_stats_meter_get_min_resolution (micro_benchmark_meter meter) ¶
-
Preconditions:
- meter points to a valid object.
- The value meter is valid.
Effects:
- None.
Postconditions:
- The returned value is meter->data.min_resolution;
- C Meter Function: micro_benchmark_stats_meter_sample micro_benchmark_stats_meter_get_max_resolution (micro_benchmark_meter meter) ¶
-
Preconditions:
- meter points to a valid object.
- meter->stop points to a valid function.
- The value meter is valid.
Effects:
- None.
Postconditions:
- The returned value is meter->data.max_resolution;