Hi.

How can I improve productivity of this code:

a_messenger_t::data_buff_t --> std::deque< some_struct >

//////////////////////////////////////////////////////////////////////////////////////////////

   char * errors = 0;

   for( a_messenger_t::data_buff_t::const_iterator it = msg.m_buff.begin(),
       last = msg.m_buff.end(); it != last; ++it )
   {
       // Converting long to std::string...
       std::string sec( itos( it->m_time.sec() ) );
       std::string usec( itos( it->m_time.usec() ) );

// Columns in 'data' table defined like (INTEGER, INTEGER, INTEGER, TEXT) char * sql = sqlite3_mprintf( "INSERT INTO data VALUES( '%q', '%q', '%q', '%q' )",
           m_sources_map[ it->m_source ].m_sid.c_str(),
           sec.c_str(), usec.c_str(), it->m_value.c_str() );

       // m_db --> sqlite3*
       int ret = sqlite3_exec( m_db, sql, 0, 0, &errors );

       if( ret != SQLITE_OK )
       {
           ACE_DEBUG( ( LM_INFO, ACE_TEXT( "[%D] %M -- %C\n" ), errors ) );
           sqlite3_free( errors );
       }

       sqlite3_free( sql );
   }

Any idea? This method are so slow - about 1 kB per second new data in my DB.

--
Regards,
Igor Mironchick,
Intervale ©
#ICQ 492-597-570


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to