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::component::written_char Struct Reference

I/O counter for chars written. The number of bytes which this task has caused, or shall cause to be written to disk. Similar caveats apply here as with tim::component::read_char (rchar). More...

#include "timemory/components/io/components.hpp"

+ Collaboration diagram for tim::component::written_char:

Public Types

using this_type = written_char
 
using value_type = std::array< int64_t, 2 >
 
using base_type = base< this_type, value_type >
 
using result_type = std::array< double, 2 >
 
using unit_type = typename trait::units< this_type >::type
 
using display_unit_type = typename trait::units< this_type >::display_type
 
using storage_type = empty_storage
 

Public Member Functions

std::string get_display () const
 
result_type get () const
 
void start ()
 
void stop ()
 
void sample ()
 sample a measurement More...
 
void sample (const cache_type &_cache)
 sample a measurement from cached data More...
 
void start (const cache_type &_cache)
 start a measurement using the cached data More...
 
void stop (const cache_type &_cache)
 stop a measurement using the cached data More...
 

Static Public Member Functions

static std::string label ()
 
static std::string description ()
 
static result_type unit ()
 
static std::vector< std::string > display_unit_array ()
 
static std::vector< std::string > label_array ()
 
static display_unit_type display_unit ()
 
static std::array< double, 2 > unit_array ()
 
static std::vector< std::string > description_array ()
 
static auto get_timestamp ()
 
static value_type record ()
 
static auto get_timing_unit ()
 
static unit_type get_unit ()
 
static display_unit_type get_display_unit ()
 
static value_type record (const cache_type &_cache)
 read the value from cached data More...
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

Detailed Description

I/O counter for chars written. The number of bytes which this task has caused, or shall cause to be written to disk. Similar caveats apply here as with tim::component::read_char (rchar).

Definition at line 258 of file components.hpp.

Member Typedef Documentation

◆ base_type

◆ display_unit_type

◆ result_type

using tim::component::written_char::result_type = std::array<double, 2>

Definition at line 263 of file components.hpp.

◆ storage_type

Definition at line 66 of file declaration.hpp.

◆ this_type

◆ unit_type

◆ value_type

using tim::component::written_char::value_type = std::array<int64_t, 2>

Definition at line 261 of file components.hpp.

Member Function Documentation

◆ description()

static std::string tim::component::written_char::description ( )
inlinestatic

Definition at line 268 of file components.hpp.

269 {
270 return "Number of bytes which this task has caused, or shall cause to be written "
271 "to disk. Similar caveats to read_char.";
272 }

◆ description_array()

static std::vector< std::string > tim::component::written_char::description_array ( )
inlinestatic

Definition at line 298 of file components.hpp.

299 {
300 return std::vector<std::string>{ "Number of char written",
301 "Rate of char written" };
302 }

◆ display_unit()

static display_unit_type tim::component::written_char::display_unit ( )
inlinestatic

Definition at line 291 of file components.hpp.

292 {
293 return display_unit_type{ { "MB", "MB/sec" } };
294 }
typename trait::units< this_type >::display_type display_unit_type
Definition: components.hpp:265

Referenced by get_display_unit().

◆ display_unit_array()

static std::vector< std::string > tim::component::written_char::display_unit_array ( )
inlinestatic

Definition at line 280 of file components.hpp.

281 {
282 return std::vector<std::string>{ std::get<0>(get_display_unit()),
283 std::get<1>(get_display_unit()) };
284 }
static display_unit_type get_display_unit()
Definition: components.hpp:405

References get_display_unit().

◆ get()

result_type tim::component::written_char::get ( ) const
inline

Definition at line 346 of file components.hpp.

347 {
348 auto val = base_type::load();
349
350 double data = std::get<0>(val);
351 double delta = std::get<1>(val);
352
353 delta /= static_cast<double>(std::nano::den);
354 delta *= get_timing_unit();
355
356 double rate = 0.0;
357 if(delta != 0.0)
358 rate = data / delta;
359
360 if(laps > 0)
361 rate *= laps;
362
363 data /= std::get<0>(get_unit());
364 rate /= std::get<0>(get_unit());
365
366 if(!std::isfinite(rate))
367 rate = 0.0;
368
369 return result_type{ { data, rate } };
370 }
bool isfinite(const Tp &arg)
Definition: utility.hpp:104
decltype(auto) load()
static unit_type get_unit()
Definition: components.hpp:382
std::array< double, 2 > result_type
Definition: components.hpp:263

References get_timing_unit(), get_unit(), tim::isfinite(), tim::component::base< written_char, std::array< int64_t, 2 > >::laps, and tim::component::base< Tp, Value >::load().

Referenced by get_display().

◆ get_display()

std::string tim::component::written_char::get_display ( ) const
inline

Definition at line 319 of file components.hpp.

320 {
321 std::stringstream ss;
322 std::stringstream ssv;
323 std::stringstream ssr;
324 auto _prec = base_type::get_precision();
325 auto _width = base_type::get_width();
326 auto _flags = base_type::get_format_flags();
327 auto _disp = get_display_unit();
328
329 auto _val = get();
330
331 ssv.setf(_flags);
332 ssv << std::setw(_width) << std::setprecision(_prec) << std::get<0>(_val);
333 if(!std::get<0>(_disp).empty())
334 ssv << " " << std::get<0>(_disp);
335
336 ssr.setf(_flags);
337 ssr << std::setw(_width) << std::setprecision(_prec) << std::get<1>(_val);
338 if(!std::get<1>(_disp).empty())
339 ssr << " " << std::get<1>(_disp);
340
341 ss << ssv.str() << ", " << ssr.str();
342 ss << " wchar";
343 return ss.str();
344 }
static short get_precision()
static short get_width()
static fmtflags get_format_flags()
result_type get() const
Definition: components.hpp:346

References get(), get_display_unit(), tim::component::base< Tp, Value >::get_format_flags(), tim::component::base< Tp, Value >::get_precision(), and tim::component::base< Tp, Value >::get_width().

◆ get_display_unit()

static display_unit_type tim::component::written_char::get_display_unit ( )
inlinestatic

Definition at line 405 of file components.hpp.

406 {
407 static display_unit_type _instance = this_type::display_unit();
408 static auto& _mem = std::get<0>(_instance);
409 static auto& _rate = std::get<1>(_instance);
410
411 if(settings::memory_units().length() > 0)
412 _mem = std::get<0>(units::get_memory_unit(settings::memory_units()));
413
414 if(settings::timing_units().length() > 0)
415 {
416 auto _tval = std::get<0>(units::get_timing_unit(settings::timing_units()));
417 _rate = mpl::apply<std::string>::join('/', _mem, _tval);
418 }
419 else if(settings::memory_units().length() > 0)
420 {
421 _rate = mpl::apply<std::string>::join('/', _mem, "sec");
422 }
423
424 return _instance;
425 }
std::tuple< std::string, int64_t > get_timing_unit(std::string _unit)
Definition: units.hpp:229
std::tuple< std::string, int64_t > get_memory_unit(std::string _unit)
Definition: units.hpp:188
memory_units
Definition: settings.cpp:1657
timing_units
Definition: settings.cpp:1650
static display_unit_type display_unit()
Definition: components.hpp:291
static string_t join(SepT &&separator, Tuple &&__tup, index_sequence< Idx... >) noexcept
Definition: apply.hpp:408

References display_unit(), tim::units::get_memory_unit(), tim::units::get_timing_unit(), tim::mpl::apply< Ret >::join(), tim::memory_units, and tim::timing_units.

Referenced by display_unit_array(), and get_display().

◆ get_opaque()

template<typename... Args>
static opaque tim::component::empty_base::get_opaque ( Args &&  ...)
inlinestaticinherited

Definition at line 72 of file declaration.hpp.

73 {
74 return opaque{};
75 }

◆ get_timestamp()

static auto tim::component::written_char::get_timestamp ( )
inlinestatic

Definition at line 304 of file components.hpp.

304{ return tim::get_clock_real_now<int64_t, std::nano>(); }

Referenced by record().

◆ get_timing_unit()

static auto tim::component::written_char::get_timing_unit ( )
inlinestatic

Definition at line 311 of file components.hpp.

312 {
313 static auto _value = units::sec;
314 if(settings::timing_units().length() > 0)
315 _value = std::get<1>(units::get_timing_unit(settings::timing_units()));
316 return _value;
317 }

References tim::units::get_timing_unit(), and tim::timing_units.

Referenced by get().

◆ get_unit()

static unit_type tim::component::written_char::get_unit ( )
inlinestatic

Definition at line 382 of file components.hpp.

383 {
384 static auto _instance = this_type::unit();
385 static auto& _mem = std::get<0>(_instance);
386 static auto& _rate = std::get<1>(_instance);
387
388 if(settings::memory_units().length() > 0)
389 _mem = std::get<1>(units::get_memory_unit(settings::memory_units()));
390
391 if(settings::timing_units().length() > 0)
392 {
393 auto _timing_val =
395 _rate = _mem / (_timing_val);
396 }
397
398 static const auto factor = static_cast<double>(std::nano::den);
399 unit_type _tmp = _instance;
400 std::get<1>(_tmp) *= factor;
401
402 return _tmp;
403 }
static result_type unit()
Definition: components.hpp:274
typename trait::units< this_type >::type unit_type
Definition: components.hpp:264

References tim::units::get_memory_unit(), tim::units::get_timing_unit(), tim::memory_units, tim::timing_units, and unit().

Referenced by get().

◆ label()

static std::string tim::component::written_char::label ( )
inlinestatic

Definition at line 267 of file components.hpp.

267{ return "written_char"; }

Referenced by label_array().

◆ label_array()

static std::vector< std::string > tim::component::written_char::label_array ( )
inlinestatic

Definition at line 286 of file components.hpp.

287 {
288 return std::vector<std::string>{ label(), "written_rate" };
289 }
static std::string label()
Definition: components.hpp:267

References label().

◆ record() [1/2]

static value_type tim::component::written_char::record ( )
inlinestatic

Definition at line 306 of file components.hpp.

307 {
308 return value_type{ { get_char_written(), get_timestamp() } };
309 }
std::array< int64_t, 2 > value_type
Definition: components.hpp:261

References get_timestamp().

Referenced by start(), and stop().

◆ record() [2/2]

static value_type tim::component::written_char::record ( const cache_type _cache)
inlinestatic

read the value from cached data

Definition at line 442 of file components.hpp.

443 {
444 return value_type{ { _cache.get_char_written(), get_timestamp() } };
445 }

References get_timestamp().

◆ sample() [1/2]

void tim::component::written_char::sample ( )
inline

sample a measurement

Definition at line 428 of file components.hpp.

429 {
430 std::get<0>(accum) = std::get<0>(value) =
431 std::max<int64_t>(std::get<0>(value), get_char_written());
432 }

◆ sample() [2/2]

void tim::component::written_char::sample ( const cache_type _cache)
inline

sample a measurement from cached data

Definition at line 435 of file components.hpp.

436 {
437 std::get<0>(accum) = std::get<0>(value) =
438 std::max<int64_t>(std::get<0>(value), _cache.get_char_written());
439 }

◆ start() [1/2]

void tim::component::written_char::start ( )
inline

Definition at line 372 of file components.hpp.

372{ value = record(); }
static value_type record()
Definition: components.hpp:306

References record().

◆ start() [2/2]

void tim::component::written_char::start ( const cache_type _cache)
inline

start a measurement using the cached data

Definition at line 448 of file components.hpp.

448{ value = record(_cache); }

References record().

◆ stop() [1/2]

void tim::component::written_char::stop ( )
inline

Definition at line 374 of file components.hpp.

375 {
376 using namespace tim::component::operators;
377 auto diff = (record() - value);
378 std::get<0>(diff) = std::abs(std::get<0>(diff));
379 accum += (value = diff);
380 }
type_list abs(type_list<>)
Definition: fwd.hpp:405

References tim::math::abs, and record().

◆ stop() [2/2]

void tim::component::written_char::stop ( const cache_type _cache)
inline

stop a measurement using the cached data

Definition at line 451 of file components.hpp.

452 {
453 using namespace tim::component::operators;
454 auto diff = (record(_cache) - value);
455 std::get<0>(diff) = std::abs(std::get<0>(diff));
456 accum += (value = diff);
457 }

References tim::math::abs, and record().

◆ unit()

static result_type tim::component::written_char::unit ( )
inlinestatic

Definition at line 274 of file components.hpp.

275 {
276 return result_type{ { units::megabyte,
277 static_cast<double>(units::megabyte) / units::sec } };
278 }

Referenced by get_unit(), and unit_array().

◆ unit_array()

static std::array< double, 2 > tim::component::written_char::unit_array ( )
inlinestatic

Definition at line 296 of file components.hpp.

296{ return unit(); }

References unit().


The documentation for this struct was generated from the following file: