timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
print_header.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2020, The Regents of the University of California,
4// through Lawrence Berkeley National Laboratory (subject to receipt of any
5// required approvals from the U.S. Dept. of Energy). All rights reserved.
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in all
15// copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23// SOFTWARE.
24
25/**
26 * \file timemory/operations/types/print_header.hpp
27 * \brief Definition for various functions for print_header in operations
28 */
29
30#pragma once
31
36
37namespace tim
38{
39namespace operation
40{
41//
42//--------------------------------------------------------------------------------------//
43//
44//
45//
46//--------------------------------------------------------------------------------------//
47//
48template <typename Tp>
50{
51 using type = Tp;
52 using widths_t = std::vector<int64_t>;
53
54 //----------------------------------------------------------------------------------//
55 // only if components are available
56 //
57 template <typename Statp, typename Up = Tp,
59 TIMEMORY_COLD print_header(const type& _obj, utility::stream& _os,
60 const Statp& _stats)
61 {
63 return;
64
65 auto _labels = get_labels(_obj);
66 // auto _display = get_display_units(_obj);
67 // std::cout << "[" << demangle<Tp>() << "]> labels: ";
68 // for(const auto& itr : _labels)
69 // std::cout << "'" << itr << "' ";
70 // std::cout << "\n";
71
72 _os.set_prefix_begin();
73 utility::write_header(_os, "LABEL");
74
76 utility::write_header(_os, "COUNT");
77
79 utility::write_header(_os, "DEPTH");
80 _os.set_prefix_end();
81
82 // auto _opzip = [](const std::string& _lhs, const std::string& _rhs) {
83 // return tim::mpl::apply<std::string>::join("", _lhs, " [", _rhs, "]");
84 // };
85
86 auto ios_fixed = std::ios_base::fixed;
87 auto ios_dec = std::ios_base::dec;
88 auto ios_showp = std::ios_base::showpoint;
89 auto f_self = ios_fixed | ios_dec | ios_showp;
90 int w_self = 8;
91 int p_self = 1;
92 auto f_value = Tp::get_format_flags();
93 auto w_value = Tp::get_width();
94 auto p_value = Tp::get_precision();
95
97 utility::write_header(_os, "METRIC");
98
100 utility::write_header(_os, "UNITS");
101
103 utility::write_header(_os, "SUM", f_value, w_value, p_value);
104
106 utility::write_header(_os, "MEAN", f_value, w_value, p_value);
107
110
112 utility::write_header(_os, "% SELF", f_self, w_self, p_self);
113
114 _os.insert_break();
115 if(!_labels.empty())
116 {
117 for(size_t i = 0; i < _labels.size() - 1; ++i)
118 {
120 utility::write_header(_os, "METRIC");
121
123 utility::write_header(_os, "UNITS");
124
126 utility::write_header(_os, "SUM", f_value, w_value, p_value);
127
129 utility::write_header(_os, "MEAN", f_value, w_value, p_value);
130
133
135 utility::write_header(_os, "% SELF", f_self, w_self, p_self);
136
137 _os.insert_break();
138 }
139 }
140 }
141
142 template <typename... Args, typename Up = Tp,
144 print_header(const type&, utility::stream&, Args&&...)
145 {}
146};
147//
148//--------------------------------------------------------------------------------------//
149//
150} // namespace operation
151} // namespace tim
auto write_header(Args &&... args)
Definition: stream.hpp:989
Definition: kokkosp.cpp:39
typename std::enable_if< B, T >::type enable_if_t
Alias template for enable_if.
Definition: types.hpp:190
The declaration for the types for operations without definitions.
Include the macros for operations.
Declare the operations types.
Definition for various functions for print_statistics in operations.
void set_prefix_begin(int val=-1)
Definition: stream.hpp:381
void insert_break(int val=-1)
Definition: stream.hpp:391
void set_prefix_end(int val=-1)
Definition: stream.hpp:386
common string manipulation utilities
static strvec_t get_labels(const Tp &_data)
print_header(const type &, utility::stream &, Args &&...)
std::vector< int64_t > widths_t
print_header(const type &_obj, utility::stream &_os, const Statp &_stats)
static void get_header(utility::stream &_os, const Sp< Vp > &)
trait that allows runtime configuration of reporting certain types of values. Only applies to text ou...
trait that signifies that an implementation is enabled at runtime. The value returned from get() is f...