add size logging to various classes

This commit is contained in:
Arvid Norberg 2010-02-08 04:51:34 +00:00
parent c75e38e855
commit 7e343a9d6f
4 changed files with 124 additions and 2 deletions

View File

@ -43,6 +43,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#include "libtorrent/debug.hpp" // for logger
#endif
namespace libtorrent
{
class TORRENT_EXPORT stat_channel
@ -51,6 +55,25 @@ namespace libtorrent
public:
enum { history = 10 };
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#define PRINT_SIZEOF(x) l << "sizeof(" #x "): " << sizeof(x) << "\n";
#define PRINT_OFFSETOF(x, y) l << " offsetof(" #x "," #y "): " << offsetof(x, y) << "\n";
static void print_size(logger& l)
{
PRINT_SIZEOF(stat_channel)
PRINT_OFFSETOF(stat_channel, m_rate_history)
PRINT_OFFSETOF(stat_channel, m_window)
PRINT_OFFSETOF(stat_channel, m_counter)
PRINT_OFFSETOF(stat_channel, m_total_counter)
PRINT_OFFSETOF(stat_channel, m_rate_sum)
}
#undef PRINT_SIZEOF
#undef PRINT_OFFSETOF
#endif
stat_channel()
: m_window(3)
, m_counter(0)

View File

@ -75,7 +75,7 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
struct logger;
#endif
@ -727,6 +727,10 @@ namespace libtorrent
// that are not private
void lsd_announce();
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
static void print_size(logger& l);
#endif
private:
void on_files_deleted(int ret, disk_io_job const& j);

View File

@ -502,7 +502,13 @@ namespace aux {
#define PRINT_SIZEOF(x) (*m_logger) << "sizeof(" #x "): " << sizeof(x) << "\n";
#define PRINT_OFFSETOF(x, y) (*m_logger) << " offsetof(" #x "," #y "): " << offsetof(x, y) << "\n";
PRINT_SIZEOF(torrent)
PRINT_SIZEOF(request_callback)
PRINT_SIZEOF(stat)
PRINT_SIZEOF(bandwidth_channel)
PRINT_SIZEOF(policy)
stat_channel::print_size(*m_logger);
torrent::print_size(*m_logger);
PRINT_SIZEOF(peer_connection)
PRINT_SIZEOF(bt_peer_connection)
PRINT_SIZEOF(address)

View File

@ -196,6 +196,95 @@ namespace
namespace libtorrent
{
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#define PRINT_SIZEOF(x) l << "sizeof(" #x "): " << sizeof(x) << "\n";
#define PRINT_OFFSETOF(x, y) l << " offsetof(" #x "," #y "): " << offsetof(x, y) << "\n";
void torrent::print_size(logger& l)
{
PRINT_SIZEOF(torrent)
PRINT_OFFSETOF(torrent, m_policy)
PRINT_OFFSETOF(torrent, m_active_time)
PRINT_OFFSETOF(torrent, m_finished_time)
PRINT_OFFSETOF(torrent, m_seeding_time)
PRINT_OFFSETOF(torrent, m_total_uploaded)
PRINT_OFFSETOF(torrent, m_total_downloaded)
PRINT_OFFSETOF(torrent, m_started)
PRINT_OFFSETOF(torrent, m_last_scrape)
PRINT_OFFSETOF(torrent, m_upload_mode_time)
PRINT_OFFSETOF(torrent, m_torrent_file)
PRINT_OFFSETOF(torrent, m_owning_storage)
PRINT_OFFSETOF(torrent, m_storage)
PRINT_OFFSETOF(torrent, m_connections)
PRINT_OFFSETOF(torrent, m_web_seeds)
PRINT_OFFSETOF(torrent, m_web_seeds_next_retry)
PRINT_OFFSETOF(torrent, m_resolving_web_seeds)
#ifndef TORRENT_DISABLE_EXTENSIONS
PRINT_OFFSETOF(torrent, m_extensions)
#endif
PRINT_OFFSETOF(torrent, m_host_resolver)
#ifndef TORRENT_DISABLE_DHT
PRINT_OFFSETOF(torrent, m_dht_announce_timer)
#endif
PRINT_OFFSETOF(torrent, m_tracker_timer)
#ifndef TORRENT_DISABLE_DHT
PRINT_OFFSETOF(torrent, m_last_dht_announce)
#endif
PRINT_OFFSETOF(torrent, m_stat)
PRINT_OFFSETOF(torrent, m_ses)
PRINT_OFFSETOF(torrent, m_file_priority)
PRINT_OFFSETOF(torrent, m_file_progress)
PRINT_OFFSETOF(torrent, m_picker)
PRINT_OFFSETOF(torrent, m_trackers)
PRINT_OFFSETOF(torrent, m_time_critical_pieces)
PRINT_OFFSETOF(torrent, m_average_piece_time)
PRINT_OFFSETOF(torrent, m_piece_time_deviation)
PRINT_OFFSETOF(torrent, m_total_failed_bytes)
PRINT_OFFSETOF(torrent, m_total_redundant_bytes)
PRINT_OFFSETOF(torrent, m_padding)
PRINT_OFFSETOF(torrent, m_username)
PRINT_OFFSETOF(torrent, m_password)
PRINT_OFFSETOF(torrent, m_net_interface)
PRINT_OFFSETOF(torrent, m_save_path)
PRINT_OFFSETOF(torrent, m_verified)
PRINT_OFFSETOF(torrent, m_num_verified)
PRINT_OFFSETOF(torrent, m_available_free_upload)
PRINT_OFFSETOF(torrent, m_storage_mode)
PRINT_OFFSETOF(torrent, m_state)
PRINT_OFFSETOF(torrent, m_error)
PRINT_OFFSETOF(torrent, m_error_file)
PRINT_OFFSETOF(torrent, m_resume_data)
PRINT_OFFSETOF(torrent, m_resume_entry)
PRINT_OFFSETOF(torrent, m_name)
#ifndef TORRENT_DISABLE_ENCRYPTION
PRINT_OFFSETOF(torrent, m_obfuscated_hash)
#endif
PRINT_OFFSETOF(torrent, m_settings)
PRINT_OFFSETOF(torrent, m_storage_constructor)
PRINT_OFFSETOF(torrent, m_progress_ppm)
PRINT_OFFSETOF(torrent, m_ratio)
PRINT_OFFSETOF(torrent, m_max_uploads)
PRINT_OFFSETOF(torrent, m_num_uploads)
PRINT_OFFSETOF(torrent, m_max_connections)
PRINT_OFFSETOF(torrent, m_block_size)
PRINT_OFFSETOF(torrent, m_complete)
PRINT_OFFSETOF(torrent, m_incomplete)
#ifdef TORRENT_DEBUG
PRINT_OFFSETOF(torrent, m_initial_done)
#endif
PRINT_OFFSETOF(torrent, m_deficit_counter)
PRINT_OFFSETOF(torrent, m_sequence_number)
PRINT_OFFSETOF(torrent, m_last_working_tracker)
PRINT_OFFSETOF(torrent, m_failed_trackers)
PRINT_OFFSETOF(torrent, m_time_scaler)
PRINT_OFFSETOF(torrent, m_priority)
}
#undef PRINT_SIZEOF
#undef PRINT_OFFSETOF
#endif
torrent::torrent(
session_impl& ses
, tcp::endpoint const& net_interface