op_stat_scalar_write()
Abstract
Writes a numeric value to a scalar statistic.
Syntax
op_stat_scalar_write (scstat_name, value)
| Argument | Type | Description |
|---|---|---|
scstat_name |
const char * |
name of the scalar statistic-of-interest |
value |
double |
value to write to the specified statistic |
Return Type
void
No return value.
Example
/* At end of simulation, scalar performance statistics */
/* and input parameters are written out. */
/* Only one station needs to do this */
if (!fddi_sink_scalar_write)
{
/* set the scalar write flag */
fddi_sink_scalar_write = 1;
op_stat_scalar_write ("Mean End-to-End Delay (sec.)",
fddi_sink_accum_delay / fddi_sink_total_pkts);
op_stat_scalar_write ("Throughput (bits/sec)",
fddi_sink_total_bits / op_sim_time ());
op_stat_scalar_write ("Peak End-to-End Delay (sec.)", fddi_sink_peak_delay);
op_stat_scalar_write ("TTRT (sec.)", Fddi_T_Opr);
}
Details
Scalar statistics can be written anytime during simulation. Multiple invocations of this KP create multiple values for the same scalar statistic; when these types of statistics are plotted, they produce plots with multiple ordinate values for a common abscissa value.
Scalar statistic values are recorded in the output vector file specified by the ov_file preference of a simulation. Unlike vector data, scalar data is not written unless a vector output file name is specified. In other words, the default behavior of a simulation is to not record any scalar data, even if calls to op_stat_scalar_write() are executed.
Purpose
Provides a mechanism to write a user-defined value as the specified scalar statistic. The written value is stored in the vector output file of the simulation. Scalar statistics are used to capture time-independent, summary values, such as average values, final values, or maximum values of time-varying state quantities.
Errors
- Program Abort: Segmentation violation. (due to an invalid scalar statistic name string)
- Recoverable Error: Allocation of memory failed.
Reference
- Use the KP op_stat_local_read() to read the current value of an input statistic
- Use the KP op_stat_scalar_write_symbol() to write a symbolic value to a scalar statistic
- Use the KP op_stat_write() to write a value to an output statistic that is tagged with the current simulation time
- Use the KP op_stat_write_t() to write a value to an output statistic that is tagged with a specified simulation time