define fixes for disk stats build configurations
This commit is contained in:
parent
89ac9916d7
commit
cf6dc377c9
|
@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef TORRENT_DISK_IO_THREAD
|
#ifndef TORRENT_DISK_IO_THREAD
|
||||||
#define TORRENT_DISK_IO_THREAD
|
#define TORRENT_DISK_IO_THREAD
|
||||||
|
|
||||||
#ifdef TORRENT_DISK_STATS
|
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -213,12 +213,12 @@ namespace libtorrent
|
||||||
boost::pool<page_aligned_allocator> m_pool;
|
boost::pool<page_aligned_allocator> m_pool;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TORRENT_STATS
|
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
|
||||||
int m_allocations;
|
int m_allocations;
|
||||||
std::map<std::string, int> m_categories;
|
|
||||||
std::map<char*, std::string> m_buf_to_category;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef TORRENT_DISK_STATS
|
#ifdef TORRENT_DISK_STATS
|
||||||
|
std::map<std::string, int> m_categories;
|
||||||
|
std::map<char*, std::string> m_buf_to_category;
|
||||||
std::ofstream m_log;
|
std::ofstream m_log;
|
||||||
#endif
|
#endif
|
||||||
#ifdef TORRENT_DEBUG
|
#ifdef TORRENT_DEBUG
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace libtorrent
|
||||||
, m_pool(block_size)
|
, m_pool(block_size)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_STATS
|
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
|
||||||
m_allocations = 0;
|
m_allocations = 0;
|
||||||
#endif
|
#endif
|
||||||
#ifdef TORRENT_DISK_STATS
|
#ifdef TORRENT_DISK_STATS
|
||||||
|
@ -108,8 +108,10 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TORRENT_STATS
|
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
|
||||||
++m_allocations;
|
++m_allocations;
|
||||||
|
#endif
|
||||||
|
#ifdef TORRENT_DISK_STATS
|
||||||
++m_categories[category];
|
++m_categories[category];
|
||||||
m_buf_to_category[ret] = category;
|
m_buf_to_category[ret] = category;
|
||||||
m_log << log_time() << " " << category << ": " << m_categories[category] << "\n";
|
m_log << log_time() << " " << category << ": " << m_categories[category] << "\n";
|
||||||
|
@ -122,8 +124,10 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(buf);
|
TORRENT_ASSERT(buf);
|
||||||
mutex_t::scoped_lock l(m_pool_mutex);
|
mutex_t::scoped_lock l(m_pool_mutex);
|
||||||
TORRENT_ASSERT(m_magic == 0x1337);
|
TORRENT_ASSERT(m_magic == 0x1337);
|
||||||
#ifdef TORRENT_STATS
|
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
|
||||||
--m_allocations;
|
--m_allocations;
|
||||||
|
#endif
|
||||||
|
#ifdef TORRENT_DISK_STATS
|
||||||
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
|
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
|
||||||
!= m_categories.end());
|
!= m_categories.end());
|
||||||
std::string const& category = m_buf_to_category[buf];
|
std::string const& category = m_buf_to_category[buf];
|
||||||
|
@ -169,8 +173,10 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef TORRENT_STATS
|
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
|
||||||
m_allocations += num_blocks;
|
m_allocations += num_blocks;
|
||||||
|
#endif
|
||||||
|
#ifdef TORRENT_DISK_STATS
|
||||||
m_categories[category] += num_blocks;
|
m_categories[category] += num_blocks;
|
||||||
m_buf_to_category[ret] = category;
|
m_buf_to_category[ret] = category;
|
||||||
m_log << log_time() << " " << category << ": " << m_categories[category] << "\n";
|
m_log << log_time() << " " << category << ": " << m_categories[category] << "\n";
|
||||||
|
@ -184,8 +190,10 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(num_blocks >= 1);
|
TORRENT_ASSERT(num_blocks >= 1);
|
||||||
mutex_t::scoped_lock l(m_pool_mutex);
|
mutex_t::scoped_lock l(m_pool_mutex);
|
||||||
TORRENT_ASSERT(m_magic == 0x1337);
|
TORRENT_ASSERT(m_magic == 0x1337);
|
||||||
#ifdef TORRENT_STATS
|
#if defined TORRENT_DISK_STATS || defined TORRENT_STATS
|
||||||
m_allocations -= num_blocks;
|
m_allocations -= num_blocks;
|
||||||
|
#endif
|
||||||
|
#ifdef TORRENT_DISK_STATS
|
||||||
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
|
TORRENT_ASSERT(m_categories.find(m_buf_to_category[buf])
|
||||||
!= m_categories.end());
|
!= m_categories.end());
|
||||||
std::string const& category = m_buf_to_category[buf];
|
std::string const& category = m_buf_to_category[buf];
|
||||||
|
|
Loading…
Reference in New Issue