Simple Runtime Analyzer
|
This section provides practical and safety tips for using the Simple Runtime Analyzer library effectively. By following these recommendations, you can avoid common errors and ensure the reliability of your performance analysis.
std::views::zip
. Therefore, it's essential to use a compiler that fully supports this version of the standard (e.g., GCC 13+, Clang 16+, or MSVC 19.34+).sra::save_report
and sra::save_samples
, in try-catch
blocks to gracefully handle exceptions like std::runtime_error
.sra::profile_runtime
, ensure that your sample container is not empty. Failure to do so will throw a std::invalid_argument
exception. You can use std::ranges::empty(samples)
to perform a safe check before profiling.sra::measure_duration
, it's a good practice to specify the desired time unit, as the default is milliseconds (ms
). For example, use measure_duration<std::chrono::nanoseconds>(...)
for high-precision measurements.RuntimeProfile
: Statistical analysis functions like sra::calculate_average
and sra::calculate_total
handle empty profiles safely. If a profile contains no data, they will simply return a zero value for the corresponding time unit, so you don't need to perform a manual check in your code.sra::generate_sizes
, note that the function will return an empty container if sample_count
is 0 or if max_sample_size
is less than the round_to
value in the configuration.sra::detail::FillerFunction
concept. This is a design requirement to ensure type safety and the correct operation of sra::generate_samples
.sra::save_samples
, be sure to use the supported file extensions: .txt
, .csv
, or .json
. Using an unsupported extension will throw a std::runtime_error
exception.sample_utils.hpp
code uses an internal detail::escape_json
function to automatically escape special characters in data strings. This ensures the generated JSON file is always valid and can be processed by other programs without syntax errors.save_samples
, the sra::save_report
function only accepts the extensions .txt
, .csv
, and .json
. Incorrect usage of this function will throw a std::runtime_error
exception.sra::generate_report
function to output reports to std::ostream
or std::stringstream
, specify the format using one of the valid strings: "text"
, "csv"
, or "json"
. Any other value will throw a std::invalid_argument
exception.