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.
tim::plotting Namespace Reference

Namespaces

namespace  operation
 

Typedefs

using string_t = std::string
 
using attributes_t = std::map< string_t, string_t >
 

Functions

void plot (const std::string &_label, const std::string &_prefix, const std::string &_dir, bool _echo_dart, const std::string &_json_file)
 
void echo_dart_file (const string_t &filepath, attributes_t attributes)
 
template<typename... Types>
std::enable_if_t<(sizeof...(Types) > 0), void > plot (std::string _prefix="", const std::string &_dir=settings::output_path(), bool _echo_dart=settings::dart_output(), std::string _json_file="")
 
template<typename... Types>
std::enable_if_t<(sizeof...(Types) > 0), void > plot (const string_t &_prefix, const string_t &_dir, bool _echo_dart, const string_t &_json_file)
 
 TIMEMORY_PLOTTING_LINKAGE (void) plot(const string_t &_label
 
 if (settings::debug()||settings::verbose() > 2) PRINT_HERE("%s"
 
 if (settings::python_exe().empty())
 
ifs close ()
 
 if (!exists)
 
 if (_plot.length() > 0) return
 
 if (_echo_dart) cmd+
 

Variables

const string_t_prefix
 
const string_t const string_t_dir
 
const string_t const string_t bool _echo_dart
 
const string_t const string_t bool const string_t_json_file
 
auto _info = TIMEMORY_LABEL("")
 
const auto & _file = _json_file
 
bool exists = ifs.good()
 
auto _ctor = get_env<std::string>("TIMEMORY_LIBRARY_CTOR", "")
 
auto _bann = get_env<std::string>("TIMEMORY_BANNER", "")
 
auto _plot = get_env<std::string>("TIMEMORY_CXX_PLOT_MODE", "")
 
auto cmd
 

Typedef Documentation

◆ attributes_t

using tim::plotting::attributes_t = typedef std::map<string_t, string_t>

Definition at line 47 of file types.hpp.

◆ string_t

using tim::plotting::string_t = typedef std::string

Definition at line 46 of file types.hpp.

Function Documentation

◆ close()

ifs tim::plotting::close ( )

◆ echo_dart_file()

void tim::plotting::echo_dart_file ( const string_t filepath,
attributes_t  attributes 
)
inline

Definition at line 162 of file declaration.hpp.

163{
164 auto attribute_string = [](const string_t& key, const string_t& item) {
165 return operation::join("", key, '=', "\"", item, "\"");
166 };
167
168 auto lowercase = [](string_t _str) {
169 for(auto& itr : _str)
170 itr = tolower(itr);
171 return _str;
172 };
173
174 auto contains = [&lowercase](const string_t& str, const std::set<string_t>& items) {
175 auto lstr = lowercase(str);
176 return std::any_of(items.begin(), items.end(), [&lstr](const auto& itr) {
177 return lstr.find(itr) != string_t::npos;
178 });
179 };
180
181 auto is_numeric = [](const string_t& str) -> bool {
182 return (str.find_first_not_of("0123456789.e+-*/") == string_t::npos);
183 };
184
185 if(attributes.find("name") == attributes.end())
186 {
187 auto name = filepath;
188 if(name.find('/') != string_t::npos)
189 name = name.substr(name.find_last_of('/') + 1);
190 if(name.find('\\') != string_t::npos)
191 name = name.substr(name.find_last_of('\\') + 1);
192 if(name.find('.') != string_t::npos)
193 name.erase(name.find_last_of('.'));
194 attributes["name"] = name;
195 }
196
197 if(attributes.find("type") == attributes.end())
198 {
199 if(contains(filepath, { ".jpeg", ".jpg" }))
200 {
201 attributes["type"] = "image/jpeg";
202 }
203 else if(contains(filepath, { ".png" }))
204 {
205 attributes["type"] = "image/png";
206 }
207 else if(contains(filepath, { ".tiff", ".tif" }))
208 {
209 attributes["type"] = "image/tiff";
210 }
211 else if(contains(filepath, { ".txt" }))
212 {
213 bool numeric_file = true;
214 std::ifstream ifs;
215 ifs.open(filepath);
216 if(ifs)
217 {
218 while(!ifs.eof())
219 {
221 ifs >> entry;
222 if(ifs.eof())
223 break;
224 if(!is_numeric(entry))
225 {
226 numeric_file = false;
227 break;
228 }
229 }
230 }
231 ifs.close();
232 if(numeric_file)
233 {
234 attributes["type"] = "numeric/double";
235 }
236 else
237 {
238 attributes["type"] = "text/string";
239 }
240 }
241 }
242
243 std::stringstream ss;
244 ss << "<DartMeasurementFile";
245 for(const auto& itr : attributes)
246 ss << " " << attribute_string(itr.first, itr.second);
247 ss << ">" << filepath << "</DartMeasurementFile>";
248 std::cout << ss.str() << std::endl;
249}
std::string string_t
Definition: library.cpp:57
auto join(const char *sep, Arg &&arg, Args &&... args)
Definition: declaration.hpp:74
std::string string_t
Definition: types.hpp:46
data::entry entry
Definition: stream.hpp:980
std::string string_t
Definition: utility.hpp:98

References tim::plotting::operation::join().

◆ if() [1/5]

tim::plotting::if ( exists)

Definition at line 77 of file definition.hpp.

78 {
79 fprintf(stderr,
80 "[%s]> file '%s' does not exist. Plot generation is disabled...\n",
81 _label.c_str(), _file.c_str());
82 return;
83 }
const auto & _file
Definition: definition.hpp:72

References _file.

◆ if() [2/5]

tim::plotting::if ( _echo_dart  )

◆ if() [3/5]

tim::plotting::if ( _plot.  length(),
 
)

◆ if() [4/5]

tim::plotting::if ( settings::debug()||settings::verbose()  ,
 
)

◆ if() [5/5]

tim::plotting::if ( settings::python_exe().empty()  )

Definition at line 60 of file definition.hpp.

61 {
62 fprintf(stderr, "[%s]> Empty '%s' (env: '%s'). Plot generation is disabled...\n",
63 _label.c_str(), "tim::settings::python_exe()", "TIMEMORY_PYTHON_EXE");
64 return;
65 }

◆ plot() [1/3]

void tim::plotting::plot ( const std::string &  _label,
const std::string &  _prefix,
const std::string &  _dir,
bool  _echo_dart,
const std::string &  _json_file 
)

◆ plot() [2/3]

template<typename... Types>
std::enable_if_t<(sizeof...(Types) > 0), void > tim::plotting::plot ( const string_t _prefix,
const string_t _dir,
bool  _echo_dart,
const string_t _json_file 
)

Definition at line 153 of file declaration.hpp.

155{
156 impl::plot<Types...>::generate(_prefix, _dir, _echo_dart, _json_file);
157}
const string_t const string_t bool const string_t & _json_file
Definition: definition.hpp:54
const string_t const string_t & _dir
Definition: definition.hpp:52
const string_t const string_t bool _echo_dart
Definition: definition.hpp:53
char const std::string & _prefix
Definition: config.cpp:55

◆ plot() [3/3]

template<typename... Types>
std::enable_if_t<(sizeof...(Types) > 0), void > tim::plotting::plot ( std::string  _prefix = "",
const std::string &  _dir = settings::output_path(),
bool  _echo_dart = settings::dart_output(),
std::string  _json_file = "" 
)

◆ TIMEMORY_PLOTTING_LINKAGE()

tim::plotting::TIMEMORY_PLOTTING_LINKAGE ( void  ) const &

Variable Documentation

◆ _bann

auto tim::plotting::_bann = get_env<std::string>("TIMEMORY_BANNER", "")

Definition at line 87 of file definition.hpp.

◆ _ctor

auto tim::plotting::_ctor = get_env<std::string>("TIMEMORY_LIBRARY_CTOR", "")

Definition at line 86 of file definition.hpp.

◆ _dir

◆ _echo_dart

const string_t const string_t bool tim::plotting::_echo_dart

Definition at line 53 of file definition.hpp.

Referenced by tim::plotting::operation::plot().

◆ _file

◆ _info

auto tim::plotting::_info = TIMEMORY_LABEL("")

◆ _json_file

const string_t const string_t bool const string_t& tim::plotting::_json_file
Initial value:
{
auto_lock_t lk(type_mutex<std::ostream>())
std::unique_lock< mutex_t > auto_lock_t
Unique lock type around mutex_t.
Definition: locking.hpp:42

Definition at line 53 of file definition.hpp.

Referenced by tim::plotting::operation::plot().

◆ _plot

auto tim::plotting::_plot = get_env<std::string>("TIMEMORY_CXX_PLOT_MODE", "")

Definition at line 88 of file definition.hpp.

◆ _prefix

const string_t& tim::plotting::_prefix

Definition at line 52 of file definition.hpp.

Referenced by tim::plotting::operation::plot().

◆ cmd

auto tim::plotting::cmd
Initial value:
=
operation::join(" ", settings::python_exe(), "-m", "timemory.plotting", "-f",
_file, "-t", TIMEMORY_JOIN("\"", "", _prefix, ""), "-o", _dir)
const string_t & _prefix
Definition: definition.hpp:52
python_exe
Definition: settings.cpp:1783
#define TIMEMORY_JOIN(delim,...)
Definition: macros.hpp:90

Definition at line 97 of file definition.hpp.

Referenced by tim::argparse::argument_vector::get_execv(), tim::if(), and timemory_trace_init().

◆ exists

bool tim::plotting::exists = ifs.good()

Definition at line 75 of file definition.hpp.