moab
moab::TreeStats Class Reference

Traversal statistics accumulating and reporting. More...

#include <TreeStats.hpp>

List of all members.

Public Member Functions

 TreeStats ()
 constructor
ErrorCode compute_stats (Interface *impl, EntityHandle root_node)
 Given a root node, compute the stats for a tree.
void reset_trav_stats ()
 reset traversal counters
void reset ()
 reset all counters
void print () const
 print the contents of this structure
void output_all_stats (const bool with_endl=true) const
 output all the contents of this structure on a single line
void output_trav_stats (const bool with_endl=true) const
 output just the traversal stats of this structure on a single line

Public Attributes

double initTime
unsigned int maxDepth
unsigned int numNodes
unsigned int numLeaves
double avgObjPerLeaf
unsigned int minObjPerLeaf
unsigned int maxObjPerLeaf
unsigned int nodesVisited
unsigned int leavesVisited
unsigned int numTraversals
unsigned int constructLeafObjectTests
unsigned int traversalLeafObjectTests
unsigned int boxElemTests

Private Member Functions

ErrorCode traverse (Interface *impl, EntityHandle node, unsigned int &depth)

Detailed Description

Traversal statistics accumulating and reporting.

Class to accumulate statistics on traversal performance. This structure contains the count of nodes visited at each level in a tree, and the count of traversals that ended at each level. One TrvStats structure can be used with multiple trees or multiple queries, or used on only a single tree or a single query.

Note that these traversal statistics are not related to the stats() query below, which calculates static information about a tree. These statistics relate to a tree's dynamic behavior on particular operations.

Definition at line 26 of file TreeStats.hpp.


Constructor & Destructor Documentation

constructor

Definition at line 29 of file TreeStats.hpp.

{reset();}

Member Function Documentation

ErrorCode moab::TreeStats::compute_stats ( Interface impl,
EntityHandle  root_node 
) [inline]

Given a root node, compute the stats for a tree.

Parameters:
implMOAB instance pointer
root_nodeRoot entity set for the tree

Definition at line 77 of file TreeStats.hpp.

    {
      maxDepth = 0;
      numNodes = 0;
      numLeaves = 0;
      avgObjPerLeaf = 0.0;
      minObjPerLeaf = 0;
      maxObjPerLeaf = 0;
      
      ErrorCode rval = traverse(impl, root_node, maxDepth);
      avgObjPerLeaf = (avgObjPerLeaf > 0 ? avgObjPerLeaf/(double)numLeaves : 0.0);
      return rval;
    }
void moab::TreeStats::output_all_stats ( const bool  with_endl = true) const [inline]

output all the contents of this structure on a single line

Definition at line 163 of file TreeStats.hpp.

    {
      std::cout << initTime << " " << numNodes << " " << numLeaves << " " << maxDepth << " " 
                << avgObjPerLeaf << " " << minObjPerLeaf << " " << maxObjPerLeaf << " "
                << constructLeafObjectTests << " " << boxElemTests << " "
                << nodesVisited << " " << leavesVisited << " " << numTraversals << " " << traversalLeafObjectTests << " ";
      if (with_endl) std::cout << std::endl;
    }
void moab::TreeStats::output_trav_stats ( const bool  with_endl = true) const [inline]

output just the traversal stats of this structure on a single line

Definition at line 172 of file TreeStats.hpp.

    {
      std::cout << nodesVisited << " " << leavesVisited << " " << numTraversals << " " << traversalLeafObjectTests << " ";
      if (with_endl) std::cout << std::endl;
    }
void moab::TreeStats::print ( ) const [inline]

print the contents of this structure

Definition at line 143 of file TreeStats.hpp.

                                       {
      std::cout << "Tree initialization time = " << initTime << " seconds" << std::endl;
      
      std::cout << "Num nodes         = " << numNodes << std::endl;
      std::cout << "Num leaves        = " << numLeaves << std::endl;
      std::cout << "Max depth         = " << maxDepth << std::endl << std::endl;

      std::cout << "Avg objs per leaf = " << avgObjPerLeaf << std::endl;
      std::cout << "Min objs per leaf = " << minObjPerLeaf << std::endl;
      std::cout << "Max objs per leaf = " << maxObjPerLeaf << std::endl;

      std::cout << "Construction Leaf Object Tests = " << constructLeafObjectTests << std::endl;
      std::cout << "Box-Element Tests = " << boxElemTests << std::endl;

      std::cout << "NodesVisited      = " << nodesVisited << std::endl;
      std::cout << "LeavesVisited     = " << leavesVisited << std::endl;
      std::cout << "Num Traversals    = " << numTraversals << std::endl;
      std::cout << "Traversal Leaf Object Tests = " << traversalLeafObjectTests << std::endl;
    }
void moab::TreeStats::reset ( ) [inline]

reset all counters

Definition at line 119 of file TreeStats.hpp.

reset traversal counters

Definition at line 135 of file TreeStats.hpp.

ErrorCode moab::TreeStats::traverse ( Interface impl,
EntityHandle  node,
unsigned int &  depth 
) [inline, private]

Definition at line 91 of file TreeStats.hpp.

    {
      depth++;
      numNodes++;
      std::vector<EntityHandle> children;
      children.reserve(2);
      ErrorCode rval = impl->get_child_meshsets(node, children);
      if (MB_SUCCESS != rval) return rval;
      if (children.empty()) {
        numLeaves++;
        rval = impl->get_entities_by_handle(node, children);
        if (MB_SUCCESS != rval) return rval;
        avgObjPerLeaf += children.size();
        minObjPerLeaf = std::min((unsigned int)children.size(), minObjPerLeaf);
        maxObjPerLeaf = std::max((unsigned int)children.size(), maxObjPerLeaf);
        return MB_SUCCESS;
      }
      else {
        unsigned int right_depth = depth, left_depth = depth;
        rval = traverse(impl, children[0], left_depth);
        if (MB_SUCCESS != rval) return rval;
        rval = traverse(impl, children[1], right_depth);
        if (MB_SUCCESS != rval) return rval;
        depth = std::max(left_depth, right_depth);
        return MB_SUCCESS;
      }
    }

Member Data Documentation

Definition at line 59 of file TreeStats.hpp.

Definition at line 70 of file TreeStats.hpp.

Definition at line 68 of file TreeStats.hpp.

Definition at line 53 of file TreeStats.hpp.

Definition at line 66 of file TreeStats.hpp.

Definition at line 56 of file TreeStats.hpp.

Definition at line 61 of file TreeStats.hpp.

Definition at line 60 of file TreeStats.hpp.

Definition at line 65 of file TreeStats.hpp.

Definition at line 58 of file TreeStats.hpp.

Definition at line 57 of file TreeStats.hpp.

Definition at line 67 of file TreeStats.hpp.

Definition at line 69 of file TreeStats.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines