Changeset 3983


Ignore:
Timestamp:
Nov 26, 2007, 8:20:46 PM (14 years ago)
Author:
charles
Message:

stats

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/stats.c

    r3978 r3983  
    2626    tr_session_stats single;
    2727    tr_session_stats cumulative;
    28     uint32_t bytes_up;
    29     uint32_t bytes_down;
    3028    time_t startTime;
    3129};
     
    4240        const benc_val_t * val;
    4341
    44         if(( val = tr_bencDictFindType( &top, "uploaded-mib", TYPE_INT )))
    45             setme->uploadedMiB = (uint64_t) tr_bencGetInt( val );
     42        if(( val = tr_bencDictFindType( &top, "uploaded-bytes", TYPE_INT )))
     43            setme->uploadedBytes = (uint64_t) tr_bencGetInt( val );
    4644
    47         if(( val = tr_bencDictFindType( &top, "downloaded-mib", TYPE_INT )))
    48             setme->downloadedMiB = (uint64_t) tr_bencGetInt( val );
     45        if(( val = tr_bencDictFindType( &top, "downloaded-bytes", TYPE_INT )))
     46            setme->downloadedBytes = (uint64_t) tr_bencGetInt( val );
    4947
    5048        if(( val = tr_bencDictFindType( &top, "files-added", TYPE_INT )))
     
    9088    char filename[MAX_PATH_LENGTH];
    9189    int len;
    92     benc_val_t top, *val;
     90    benc_val_t top;
    9391
    9492    tr_bencInit( &top, TYPE_DICT );
    9593    tr_bencDictReserve( &top, 5 );
    96     tr_bencInitInt( tr_bencDictAdd( &top, "uploaded-mib" ), stats->uploadedMiB );
    97     tr_bencInitInt( tr_bencDictAdd( &top, "downloaded-mib" ), stats->downloadedMiB );
     94    tr_bencInitInt( tr_bencDictAdd( &top, "uploaded-bytes" ), stats->uploadedBytes );
     95    tr_bencInitInt( tr_bencDictAdd( &top, "downloaded-bytes" ), stats->downloadedBytes );
    9896    tr_bencInitInt( tr_bencDictAdd( &top, "files-added" ), stats->filesAdded );
    9997    tr_bencInitInt( tr_bencDictAdd( &top, "session-count" ), stats->sessionCount );
     
    141139    const struct tr_stats_handle * stats = handle->sessionStats;
    142140    *setme = stats->single;
    143     setme->ratio = setme->downloadedMiB ? (double)setme->uploadedMiB / (double)setme->downloadedMiB : TR_RATIO_NA;
    144     setme->secondsActive += (time(NULL) - stats->startTime );
     141    setme->ratio = setme->uploadedBytes ? (double)setme->uploadedBytes / (double)setme->downloadedBytes : TR_RATIO_NA;
     142    setme->secondsActive += ( time(NULL) - stats->startTime );
    145143}
    146144
     
    151149    const struct tr_stats_handle * stats = handle->sessionStats;
    152150    *setme = stats->cumulative;
    153     setme->ratio = setme->downloadedMiB ? (double)setme->uploadedMiB / (double)setme->downloadedMiB : TR_RATIO_NA;
    154     setme->secondsActive += (time(NULL) - stats->startTime );
     151    setme->ratio = setme->uploadedBytes ? (double)setme->uploadedBytes / (double)setme->downloadedBytes : TR_RATIO_NA;
     152    setme->secondsActive += ( time(NULL) - stats->startTime );
    155153}
    156154
     
    159157**/
    160158
    161 #define MiB 1048576
    162 
    163159void
    164160tr_statsAddUploaded( tr_handle * handle, uint32_t bytes )
    165161{
    166162    struct tr_stats_handle * stats = handle->sessionStats;
    167     stats->bytes_up += bytes;
    168     if( stats->bytes_up >= MiB )
    169     {
    170         const uint32_t megs = stats->bytes_up / MiB;
    171         stats->bytes_up %= MiB;
    172         stats->single.uploadedMiB += megs;
    173         stats->cumulative.uploadedMiB += megs;
    174     }
     163    stats->single.uploadedBytes += bytes;
     164    stats->cumulative.uploadedBytes += bytes;
    175165}
    176166
     
    179169{
    180170    struct tr_stats_handle * stats = handle->sessionStats;
    181     stats->bytes_down += bytes;
    182     if( stats->bytes_down >= MiB )
    183     {
    184         const uint32_t megs = stats->bytes_down / MiB;
    185         stats->bytes_down %= MiB;
    186         stats->single.downloadedMiB += megs;
    187         stats->cumulative.downloadedMiB += megs;
    188     }
     171    stats->single.downloadedBytes += bytes;
     172    stats->cumulative.downloadedBytes += bytes;
    189173}
    190174
  • trunk/libtransmission/stats.h

    r3976 r3983  
    2222void tr_statsAddDownloaded( tr_handle * handle, uint32_t bytes );
    2323
     24void tr_torrentAdded( tr_handle * handle, const tr_torrent * torrent );
    2425
    2526#endif
  • trunk/libtransmission/transmission.h

    r3976 r3983  
    119119typedef struct tr_session_stats
    120120{
    121     uint64_t uploadedMiB;     /* total up */
    122     uint64_t downloadedMiB;  /* total down */
     121    uint64_t uploadedBytes;   /* total up */
     122    uint64_t downloadedBytes; /* total down */
    123123    double ratio;             /* total up / total down */
    124124    uint64_t filesAdded;      /* number of files added */
Note: See TracChangeset for help on using the changeset viewer.