Changeset 380 for trunk/src/core
- Timestamp:
- 05/29/15 17:28:16 (10 years ago)
- Location:
- trunk/src/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/library.cc
r365 r380 39 39 } 40 40 41 void library::open( const string&name )41 void library::open( string_ref name ) 42 42 { 43 m_name = name;43 m_name.assign( name.data(), name.size() ); 44 44 if ( !open() ) 45 45 { 46 46 m_handle = nullptr; 47 NV_THROW( library_error, "Can't load library!", name );47 NV_THROW( library_error, "Can't load library!", name.data() ); 48 48 } 49 49 } 50 50 51 bool nv::library::try_open( const string&name )51 bool nv::library::try_open( string_ref name ) 52 52 { 53 m_name = name;53 m_name.assign( name.data(), name.size() ); 54 54 if ( !open() ) 55 55 { … … 60 60 } 61 61 62 const string&library::get_name() const62 string_ref library::get_name() const 63 63 { 64 return m_name;64 return string_ref( m_name ); 65 65 } 66 66 … … 73 73 NV_LOG_NOTICE( "library : loading '", m_name, "'..." ); 74 74 75 string name = m_name; 76 string ext = NV_LIB_EXT; 77 size_t ext_len = ext.length(); 75 std::string name = m_name; 76 string_ref ext( NV_LIB_EXT ); 78 77 79 if ( name.length() < ext_len || name.substr( name.length() - ext_len, ext_len ) != ext ) 78 if ( name.length() < ext.length() || name.substr( name.length() - ext.length(), ext.length() ) != ext ) 80 79 { 81 name += ext;80 name.append( ext.data(), ext.length() ); 82 81 } 83 82 … … 93 92 } 94 93 95 void* library::get( const string&symbol )94 void* library::get( string_ref symbol ) 96 95 { 97 void* result = (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol. c_str() );96 void* result = (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.data() ); 98 97 if ( !result ) 99 98 { 100 NV_THROW( library_error, "Can't find symbol " + s ymbol+ "!", m_name );99 NV_THROW( library_error, "Can't find symbol " + std::string(symbol.data(),symbol.size()) + "!", m_name ); 101 100 } 102 101 return result; 103 102 } 104 103 105 void* nv::library::try_get( const string&symbol )104 void* nv::library::try_get( string_ref symbol ) 106 105 { 107 return (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol. c_str() );106 return (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.data() ); 108 107 } 109 108 … … 130 129 } 131 130 132 st ring library::get_error()131 std::string library::get_error() 133 132 { 134 133 #if NV_PLATFORM == NV_WINDOWS … … 137 136 FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 138 137 NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &buffer, 0, NULL ); 139 st ring msg( (char*)buffer );138 std::string msg( (char*)buffer ); 140 139 LocalFree( buffer ); 141 140 return msg; -
trunk/src/core/logger.cc
r376 r380 163 163 { 164 164 const char* lcolor = log_color[( level ) / 10]; 165 fwrite( lcolor, strlen(lcolor), 1, stdout );165 fwrite( lcolor, nvstrlen(lcolor), 1, stdout ); 166 166 } 167 167 fwrite( NV_LOG_LEVEL_NAME_PAD( level ), 8, 1, stdout ); -
trunk/src/core/profiler.cc
r376 r380 108 108 char buffer[128]; 109 109 snprintf( buffer, 128, "%-23s %6s %6s %9s %6s", "TAG", "%PARNT", "CALLS", "TOTAL(ms)", "AVG(ms)" ); 110 NV_LOG_INFO( string_ref( buffer, strlen(buffer) ) );110 NV_LOG_INFO( string_ref( buffer, nvstrlen( buffer ) ) ); 111 111 log_node_children( 0, m_root ); 112 112 NV_LOG_INFO( "-- PROFILER REPORT END ---------------------------------" ); … … 122 122 if ( c->m_calls > 0 ) 123 123 { 124 double pparent = ( (double)c->m_total_time_us / (double)c->m_parent->m_total_time_us ) * 100.f;125 intcalls = c->m_calls;126 doubletotal_ms = c->m_total_time_us / 1000.f;127 double avg_ms = ( (double)c->m_total_time_us / (double)c->m_calls ) / 1000.f;128 if ( indent > 0 ) memset( buffer, '-', indent );124 f64 pparent = ( (f64)c->m_total_time_us / (f64)c->m_parent->m_total_time_us ) * 100.f; 125 uint32 calls = c->m_calls; 126 f64 total_ms = c->m_total_time_us / 1000.f; 127 f64 avg_ms = ( (f64)c->m_total_time_us / (f64)c->m_calls ) / 1000.f; 128 if ( indent > 0 ) nvmemset( buffer, '-', indent ); 129 129 snprintf( buffer + indent, 128 - indent, "%*.*s %6.2f %6d %9.2f %6.2f", indent - 23, 23 - indent, 130 130 c->m_tag.c_str(), pparent, calls, total_ms, avg_ms ); 131 NV_LOG_INFO( string_ref( buffer, strlen( buffer ) ) );131 NV_LOG_INFO( string_ref( buffer, nvstrlen( buffer ) ) ); 132 132 if ( c->m_children.size() > 0 ) 133 133 { -
trunk/src/core/time.cc
r376 r380 74 74 struct timespec ts; 75 75 ts.tv_sec = 0; 76 ts.tv_nsec = ms * 1000000;76 ts.tv_nsec = (long)ms * 1000000; 77 77 nanosleep(&ts, NULL); 78 78 // usleep( ms * 1000 );
Note: See TracChangeset
for help on using the changeset viewer.