![]() |
VCSBeam
|
#include <stdlib.h>#include <stdio.h>#include <stdbool.h>#include <string.h>#include <time.h>#include <math.h>#include "vcsbeam.h"Functions | |
| double | now () |
| Gets the precise current time. More... | |
| int | get_stopwatch_idx (logger *log, const char *stopwatch_name) |
| Finds the stopwatch with the given name. More... | |
| int | get_stopwatch_max_name_length (logger *log) |
| Finds the maximum length of stopwatch names. More... | |
| double | calc_stopwatch_mean (logger_stopwatch *sw) |
| Calculates the mean duration of a stopwatch's runs. More... | |
| double | calc_stopwatch_std (logger_stopwatch *sw) |
| Calculates the standard devation of a stopwatch's runs. More... | |
| void | write_stopwatch_stats_str (logger *log, logger_stopwatch *sw, int pad_size) |
| Prints a stopwatch's statisticss (mean and std). More... | |
| logger * | create_logger (FILE *fout, int world_rank) |
| Creates a new logger object. More... | |
| void | destroy_logger (logger *log) |
| Destroys a logger object. More... | |
| void | logger_add_stopwatch (logger *log, const char *stopwatch_name, const char *description) |
| Adds a stopwatch to the logger object. More... | |
| void | logger_start_stopwatch (logger *log, const char *stopwatch_name, bool print_description) |
| Starts a stopwatch. More... | |
| void | logger_stop_stopwatch (logger *log, const char *stopwatch_name) |
| Stops a stopwatch. More... | |
| void | logger_timed_message (logger *log, const char *message) |
| Prints a timestamped log message. More... | |
| void | logger_message (logger *log, const char *message) |
| Prints a log message. More... | |
| void | logger_stopwatch_report_stats (logger *log, const char *stopwatch_name) |
| Prints a stopwatch's statistics. More... | |
| void | logger_report_all_stats (logger *log) |
| Prints all stopwatches' statistics. More... | |
| double calc_stopwatch_mean | ( | logger_stopwatch * | sw | ) |
Calculates the mean duration of a stopwatch's runs.
| sw | A stopwatch object |
sw | double calc_stopwatch_std | ( | logger_stopwatch * | sw | ) |
Calculates the standard devation of a stopwatch's runs.
| sw | A stopwatch object |
sw | logger* create_logger | ( | FILE * | fout, |
| int | world_rank | ||
| ) |
Creates a new logger object.
| fout | The file stream where to print logger messages |
| world_rank | The rank of the current MPI process |
If world_rank is a non-negative integer, the value of world_rank will be included in log messages. To avoid printing the rank, set world_rank to PERFORMANCE_NO_MPI.
| void destroy_logger | ( | logger * | log | ) |
Destroys a logger object.
| log | The logger object to be destroyed and its memory freed. |
| int get_stopwatch_idx | ( | logger * | log, |
| const char * | stopwatch_name | ||
| ) |
Finds the stopwatch with the given name.
| log | The logger object to be searched | |
| [in] | stopwatch_name | The string to be searched |
log→stopwatches where the stopwatch name matches stopwatch_name | int get_stopwatch_max_name_length | ( | logger * | log | ) |
Finds the maximum length of stopwatch names.
| log | A logger object with stopwatches |
log | void logger_add_stopwatch | ( | logger * | log, |
| const char * | stopwatch_name, | ||
| const char * | description | ||
| ) |
Adds a stopwatch to the logger object.
| log | The logger object to be added to |
| stopwatch_name | A string specifying the new stopwatch's name |
| description | A string specifying the new stopwatch's purpose |
| void logger_message | ( | logger * | log, |
| const char * | message | ||
| ) |
Prints a log message.
| log | A logger object |
| message | The message to be printed |
The message is printed to log->fout, including a trailing newline character.
| void logger_report_all_stats | ( | logger * | log | ) |
Prints all stopwatches' statistics.
| log | the logger object whose stopwatches are to be reported |
This function prints the statistics of all stopwatches which have been run at least once. The output is aligned, with each stopwatch name being padded by the same amount.
Example:
| void logger_start_stopwatch | ( | logger * | log, |
| const char * | stopwatch_name, | ||
| bool | print_description | ||
| ) |
Starts a stopwatch.
| log | The logger object containing the stopwatch to be started |
| stopwatch_name | The name of the stopwatch to be started |
| print_description | Print a timed message with the stopwatch's description |
If the stopwatch is already running, this has no effect.
| void logger_stop_stopwatch | ( | logger * | log, |
| const char * | stopwatch_name | ||
| ) |
Stops a stopwatch.
| log | The logger object containing the stopwatch to be stopped |
| stopwatch_name | The name of the stopwatch to be stopped |
If the stopwatch is already stopped, this has no effect.
| void logger_stopwatch_report_stats | ( | logger * | log, |
| const char * | stopwatch_name | ||
| ) |
Prints a stopwatch's statistics.
| log | A logger object containing the stopwatch to be reported |
| stopwatch_name | The name of the stopwatch to be reported |
A wrapper for write_stopwatch_stats_str(), where pad_size is set to zero, and the statistics are only printed if there has been at least one run for the specified stopwatch.
| void logger_timed_message | ( | logger * | log, |
| const char * | message | ||
| ) |
Prints a timestamped log message.
| log | A logger object |
| message | The message to be printed |
The message will be printed to the file stream log->fout.
If log->world_rank is non-negative, the format of the message is
Otherwise, the format is
| double now | ( | ) |
Gets the precise current time.
| void write_stopwatch_stats_str | ( | logger * | log, |
| logger_stopwatch * | sw, | ||
| int | pad_size | ||
| ) |
Prints a stopwatch's statisticss (mean and std).
| log | A logger object |
| sw | The stopwatch object whose statistics are to be printed |
| pad_size | The field width for the stopwatch name (for alignment purposes) |
Setting pad_size = 0 is the same as setting it to the number of characters in the stopwatch's name.