define fixes for disk stats build configurations

This commit is contained in:
Arvid Norberg 2009-05-04 06:42:24 +00:00
parent 89ac9916d7
commit cf6dc377c9
2 changed files with 17 additions and 9 deletions

View File

@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_DISK_IO_THREAD
#define TORRENT_DISK_IO_THREAD
#ifdef TORRENT_DISK_STATS
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
#include <fstream>
#endif
@ -213,12 +213,12 @@ namespace libtorrent
boost::pool<page_aligned_allocator> m_pool;
#endif
#ifdef TORRENT_STATS
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
int m_allocations;
std::map<std::string, int> m_categories;
std::map<char*, std::string> m_buf_to_category;
#endif
#ifdef TORRENT_DISK_STATS
std::map<std::string, int> m_categories;
std::map<char*, std::string> m_buf_to_category;
std::ofstream m_log;
#endif
#ifdef TORRENT_DEBUG

View File

@ -55,7 +55,7 @@ namespace libtorrent
, m_pool(block_size)
#endif
{
#ifdef TORRENT_STATS
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
m_allocations = 0;
#endif
#ifdef TORRENT_DISK_STATS
@ -108,8 +108,10 @@ namespace libtorrent
}
#endif
#ifdef TORRENT_STATS
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
++m_allocations;
#endif
#ifdef TORRENT_DISK_STATS
++m_categories[category];
m_buf_to_category[ret] = category;
m_log << log_time() << " " << category << ": " << m_categories[category] << "\n";
@ -122,8 +124,10 @@ namespace libtorrent
TORRENT_ASSERT(buf);
mutex_t::scoped_lock l(m_pool_mutex);
TORRENT_ASSERT(m_magic == 0x1337);
#ifdef TORRENT_STATS
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
--m_allocations;
#endif
#ifdef TORRENT_DISK_STATS
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
!= m_categories.end());
std::string const& category = m_buf_to_category[buf];
@ -169,8 +173,10 @@ namespace libtorrent
#endif
}
#endif
#ifdef TORRENT_STATS
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
m_allocations += num_blocks;
#endif
#ifdef TORRENT_DISK_STATS
m_categories[category] += num_blocks;
m_buf_to_category[ret] = category;
m_log << log_time() << " " << category << ": " << m_categories[category] << "\n";
@ -184,8 +190,10 @@ namespace libtorrent
TORRENT_ASSERT(num_blocks >= 1);
mutex_t::scoped_lock l(m_pool_mutex);
TORRENT_ASSERT(m_magic == 0x1337);
#ifdef TORRENT_STATS
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
m_allocations -= num_blocks;
#endif
#ifdef TORRENT_DISK_STATS
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
!= m_categories.end());
std::string const& category = m_buf_to_category[buf];