profiler  0.0
molpro::profiler::dotgraph Namespace Reference

Classes

class  GraphEntry
 

Enumerations

enum  EntryType {
  node ,
  edge
}
 

Functions

std::string blend_colours (double ratio, int hot_colour[3], int cool_colour[3])
 Simple additive blending of two colours. May be reduced with nicer colour blending in the future. More...
 
std::string print_time (double time, double total_time, bool show_percentage_time)
 Returns a string with the runtime of a node. More...
 
std::string make_box (std::string name, double time, double total_time, size_t call_count, size_t opcount, int hot[3], int cool[3], bool show_percentage_time)
 Create a graphviz box of a profiler node. More...
 
std::string make_arrow (std::string name_from, std::string name_to, double time, double total_time, size_t call_count, int hot[3], int cool[3], bool show_percentage_time)
 Create a graphviz arrow of a profiler node. More...
 
void combine_graph_entries (GraphEntry &entry1, GraphEntry &entry2)
 Combines two graph entries, summing their time, calls and opcount. More...
 
void merge_vec (std::vector< GraphEntry > &graph_entries)
 Iterates through the list of GraphEntries and merges any two nodes with the same name. The implementation is a little complex, it removes elements from the vector as it goes and has to update the iterators to correct for entries being deleted. More...
 
void apply_threshold (std::vector< GraphEntry > &graph_entries, double threshold, double total_time)
 This removes any enntry from graph_entries with a runtime/total_time less than threshold. More...
 
bool has_parent (GraphEntry &child, std::vector< GraphEntry > &graph_entries)
 Determines if a node has a parent. More...
 
void destroy_orphans (std::vector< GraphEntry > &graph_entries)
 Removes every element from graph_entries that does not have an edge pointing towards it (unless it's the root node). More...
 
std::string get_graph_markup (std::vector< GraphEntry > &graph_entries, double total_time, int hot[3], int cool[3], bool show_percentage_time)
 This gets the graphviz markup for the main part of the graph (excepting global styles). More...
 
void make_dotgraph_vec (std::shared_ptr< Node< Counter >> root, double total_time, std::vector< GraphEntry > &graph_entries)
 This populates a vector containing a GraphEntry for each profiler node. This is an intermediate data structure to make it easier to merge profiler nodes but retain their connectivity. More...
 
std::string make_dotgraph (std::shared_ptr< Node< Counter >> root, double total_time, int hot[3], int cool[3], double threshold, bool show_percentage_time)
 This creates the complete graphviz markup for the whole performance graph, including global styles. The output from this function can be written to a .dot file. More...
 

Enumeration Type Documentation

◆ EntryType

Enumerator
node 
edge 

Function Documentation

◆ apply_threshold()

void molpro::profiler::dotgraph::apply_threshold ( std::vector< GraphEntry > &  graph_entries,
double  threshold,
double  total_time 
)

This removes any enntry from graph_entries with a runtime/total_time less than threshold.

Parameters
graph_entriesa vector filled with GraphEntry objects.
thresholdthe threshold below which the entry will be deleted (as a ratio)
total_timetotal runntime of the profile.
Returns
nothing, but modifies graph_entries.

◆ blend_colours()

std::string molpro::profiler::dotgraph::blend_colours ( double  ratio,
int  hot_colour[3],
int  cool_colour[3] 
)

Simple additive blending of two colours. May be reduced with nicer colour blending in the future.

Parameters
ratioratio of the colours. A double between 0 and 1. 1 is hot, 0 is cool.
hot_colouran 8-bit colour, 0-255.
cool_colouran 8-bit colour, 0-255.
Returns
the colour, in hex format, as a string, e.g. #fffeee

◆ combine_graph_entries()

void molpro::profiler::dotgraph::combine_graph_entries ( GraphEntry entry1,
GraphEntry entry2 
)

Combines two graph entries, summing their time, calls and opcount.

Parameters
entry1the graph entry that entry2 will be merged into.
entry2the graph entry that will be merged into entry1.
Returns
nothing, modifies entry1. If you use this function, erase entry2 afterward.

◆ destroy_orphans()

void molpro::profiler::dotgraph::destroy_orphans ( std::vector< GraphEntry > &  graph_entries)

Removes every element from graph_entries that does not have an edge pointing towards it (unless it's the root node).

Parameters
graph_entriesa vector filled with GraphEntry objects, normally found in make_dotgraph_vec
Returns
nothing, modifies graph_entries.

◆ get_graph_markup()

std::string molpro::profiler::dotgraph::get_graph_markup ( std::vector< GraphEntry > &  graph_entries,
double  total_time,
int  hot[3],
int  cool[3],
bool  show_percentage_time 
)

This gets the graphviz markup for the main part of the graph (excepting global styles).

Parameters
graph_entriesa vector filled with GraphEntry objects.
total_timethe total time taken by the program, in seconds.
hotan 8-bit colour, 0-255. The more time spent in this node, the hotter the colour will be.
coolan 8-bit colour, 0-255.
show_percentage_timewhether to show the time as a percentage of the runtime (true) or in seconds (false).
Returns
a string containing graphviz markup for nodes and edges.

◆ has_parent()

bool molpro::profiler::dotgraph::has_parent ( GraphEntry child,
std::vector< GraphEntry > &  graph_entries 
)

Determines if a node has a parent.

Parameters
child- a single graph_entry
graph_entriesa vector filled with GraphEntry objects.
Returns
true if child has a parent in graph_entries, false if it does not.

◆ make_arrow()

std::string molpro::profiler::dotgraph::make_arrow ( std::string  name_from,
std::string  name_to,
double  time,
double  total_time,
size_t  call_count,
int  hot[3],
int  cool[3],
bool  show_percentage_time 
)

Create a graphviz arrow of a profiler node.

Parameters
name_fromname the name of the box that the arrow is coming from.
rationame the name of the box that the arrow is going to.
timetime time taken for the node, in seconds.
total_timethe total time taken by the program, in seconds.
call_countthe number of times the node has been called.
hotan 8-bit colour, 0-255. The more time spent in this node, the hotter the colour will be.
coolan 8-bit colour, 0-255.
show_percentage_timewhether to show the time as a percentage of the runtime (true) or in seconds (false).
Returns
the arrow, as graphviz markup.

◆ make_box()

std::string molpro::profiler::dotgraph::make_box ( std::string  name,
double  time,
double  total_time,
size_t  call_count,
size_t  opcount,
int  hot[3],
int  cool[3],
bool  show_percentage_time 
)

Create a graphviz box of a profiler node.

Parameters
rationame the name of the box.
timetime time taken for the node, in seconds.
total_timethe total time taken by the program, in seconds.
call_countthe number of times the node has been called.
opcountthe number of operations (used to calculate frequency)
hotan 8-bit colour, 0-255. The more time spent in this node, the hotter the colour will be.
coolan 8-bit colour, 0-255.
show_percentage_timewhether to show the time as a percentage of the runtime (true) or in seconds (false).
Returns
the box, as graphviz markup.

◆ make_dotgraph()

std::string molpro::profiler::dotgraph::make_dotgraph ( std::shared_ptr< Node< Counter >>  root,
double  total_time,
int  hot[3],
int  cool[3],
double  threshold,
bool  show_percentage_time 
)

This creates the complete graphviz markup for the whole performance graph, including global styles. The output from this function can be written to a .dot file.

Parameters
rootthe root of the tree of nodes as defined in node.h.
total_timethe total time taken by the program, in seconds.
hotan 8-bit colour, 0-255. The more time spent in this node, the hotter the colour will be.
coolan 8-bit colour, 0-255.
thresholda value between 0 and 1, a ratio of the program's runtime. If the program spends less than this value in a given function, the box will not be drawn.
show_percentage_timewhether to show the time as a percentage of the runtime (true) or in seconds (false).
Returns
graphviz markup for the profile.

◆ make_dotgraph_vec()

void molpro::profiler::dotgraph::make_dotgraph_vec ( std::shared_ptr< Node< Counter >>  root,
double  total_time,
std::vector< GraphEntry > &  graph_entries 
)

This populates a vector containing a GraphEntry for each profiler node. This is an intermediate data structure to make it easier to merge profiler nodes but retain their connectivity.

Parameters
rootthe root of the tree of nodes as defined in node.h.
total_timethe total time taken by the program, in seconds.
thresholda value between 0 and 1, a ratio of the program's runtime. If the program spends less than this value in a given function, the box will not be drawn.
graph_entriesa vector (most likely empty) that will be filled with GraphEntry objects.
Returns
nothing, but populates graph_entries.

◆ merge_vec()

void molpro::profiler::dotgraph::merge_vec ( std::vector< GraphEntry > &  graph_entries)

Iterates through the list of GraphEntries and merges any two nodes with the same name. The implementation is a little complex, it removes elements from the vector as it goes and has to update the iterators to correct for entries being deleted.

Parameters
graph_entriesa vector filled with GraphEntry objects, normally found in make_dotgraph_vec
Returns
nothing, modifies graph_entries.

◆ print_time()

std::string molpro::profiler::dotgraph::print_time ( double  time,
double  total_time,
bool  show_percentage_time 
)

Returns a string with the runtime of a node.

Parameters
timeThe runtime of the node
total_timethe total runtime of the tree.
show_percentage_timeif true, will show a percentage, otherwise will show the time in seconds.
Returns
a string with the runtime of the node.