Changeset 409
- Timestamp:
- 06/21/15 02:44:51 (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/core/profiler.hh
r399 r409 17 17 #include <nv/stl/singleton.hh> 18 18 #include <nv/stl/string.hh> 19 #include <nv/stl/ unordered_map.hh>19 #include <nv/stl/string_map.hh> 20 20 21 21 #if NV_PROFILER 22 #define NV_PROFILE( tag ) nv::profiler_guard __profile( tag )23 #define NV_PROFILE_IF( tag, condition ) nv::profiler_condition_guard __profile( tag , condition )22 #define NV_PROFILE( tag ) nv::profiler_guard __profile( tag##_hls64 ) 23 #define NV_PROFILE_IF( tag, condition ) nv::profiler_condition_guard __profile( tag##_hls64, condition ) 24 24 #else 25 25 #define NV_PROFILE( tag ) … … 33 33 { 34 34 protected: 35 typedef hashed_literal_string_64 string_type; 36 35 37 class node 36 38 { 39 friend class profiler; 37 40 public: 38 friend class profiler; 41 ~node(); 42 protected: 43 node( string_view tag, node* parent ); 39 44 node* get_parent() { return m_parent; } 40 node* get_child( const std::string& tag ) 41 { 42 auto it = m_children.find( tag ); 43 return ( it != m_children.end() ) ? it->second : nullptr; 44 } 45 protected: 46 node( const string_view& tag, node* parent ); 47 node* request_child( const string_view& tag ); 45 node* request_child( string_type&& tag ); 48 46 void start(); 49 47 bool stop(); 50 ~node();51 protected:52 typedef unordered_map< std::string, node* > map;53 48 54 std::string m_tag; 49 typedef literal_map< node* > map; 50 51 string_view m_tag; 55 52 map m_children; 56 53 node* m_parent; … … 66 63 ~profiler(); 67 64 68 void start_profile( const string_view& tag );65 void start_profile( string_type&& tag ); 69 66 void stop_profile(); 70 67 public: … … 82 79 { 83 80 public: 84 profiler_guard( string_viewtag )81 profiler_guard( hashed_literal_string_64&& tag ) 85 82 { 86 profiler::pointer()->start_profile( tag);83 profiler::pointer()->start_profile( ::nv::move( tag ) ); 87 84 } 88 85 … … 96 93 { 97 94 public: 98 profiler_condition_guard( string_viewtag, bool condition )95 profiler_condition_guard( hashed_literal_string_64&& tag, bool condition ) 99 96 : m_active( condition ) 100 97 { 101 if ( m_active ) profiler::pointer()->start_profile( tag);98 if ( m_active ) profiler::pointer()->start_profile( ::nv::move( tag ) ); 102 99 } 103 100 -
trunk/src/core/profiler.cc
r402 r409 20 20 profiler::profiler() 21 21 { 22 m_root = new node( "root" , nullptr );22 m_root = new node( "root"_hls64, nullptr ); 23 23 m_root->start(); 24 24 m_current = m_root; … … 30 30 } 31 31 32 void profiler::start_profile( const string_view& tag )32 void profiler::start_profile( string_type&& tag ) 33 33 { 34 34 if ( tag != m_current->m_tag ) 35 35 { 36 m_current = m_current->request_child( tag);36 m_current = m_current->request_child( ::nv::move( tag ) ); 37 37 } 38 38 m_current->start(); … … 47 47 } 48 48 49 profiler::node::node( const string_view&tag, node* parent )50 : m_tag( tag.to_string() )49 profiler::node::node( string_view tag, node* parent ) 50 : m_tag( ::nv::move( tag ) ) 51 51 , m_parent( parent ) 52 52 , m_recusion( 0 ) … … 58 58 } 59 59 60 profiler::node* profiler::node::request_child( const string_view& tag )60 profiler::node* profiler::node::request_child( string_type&& tag ) 61 61 { 62 std::string stag( tag.to_string() ); 63 auto it = m_children.find( stag ); 62 auto it = m_children.find( tag ); 64 63 if ( it != m_children.end() ) 65 64 return it->second; … … 67 66 { 68 67 node* result = new node( tag, this ); 69 m_children [ stag ] = result;68 m_children.assign( ::nv::move( tag ), result ); 70 69 return result; 71 70 } … … 131 130 if ( indent > 0 ) nvmemset( buffer, '-', indent ); 132 131 snprintf( buffer + indent, 128 - indent, "%*.*s %6.2f %6d %9.2f %6.2f", indent - 23, 23 - indent, 133 c->m_tag. c_str(), pparent, calls, total_ms, avg_ms );132 c->m_tag.data(), pparent, calls, total_ms, avg_ms ); 134 133 NV_LOG_INFO( string_view( buffer, nvstrlen( buffer ) ) ); 135 134 if ( c->m_children.size() > 0 )
Note: See TracChangeset
for help on using the changeset viewer.