summaryrefslogtreecommitdiff
path: root/src/Peer.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-10-25 23:33:45 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-10-25 23:33:45 +0900
commit0ecfa19925453e3e4bf8ca947dc72a597654e401 (patch)
tree09e2a91ca926e58489bee5c4ba2ae3ba2ba102de /src/Peer.cc
parent46bdaf0e8dae04d223d9b8b65ac80bc0773d8398 (diff)
Reworked download/upload statistics calculation
The old implementation calculates download/upload statistics for a RequestGroup by summing up all PeerStat objects. For global statistics, those are summed together. This clearly incurs runtime penalty and we introduced some kind of caching which updates statistics every 250ms but it did not work right. This change removes all these aggregation code, and instead makes RequestGroup and RequestGroupMan objects hold NetStat object and download/upload bytes are directly calculated by thier own NetStat. This is far more simplar than the old way and less runtime penalty and brings more accuracy.
Diffstat (limited to 'src/Peer.cc')
-rw-r--r--src/Peer.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Peer.cc b/src/Peer.cc
index caac3f43..b4fc13ac 100644
--- a/src/Peer.cc
+++ b/src/Peer.cc
@@ -77,7 +77,7 @@ void Peer::allocateSessionResource(int32_t pieceLength, int64_t totalLength)
{
delete res_;
res_ = new PeerSessionResource(pieceLength, totalLength);
- res_->getPeerStat().downloadStart();
+ res_->getNetStat().downloadStart();
updateSeeder();
}
@@ -219,13 +219,13 @@ void Peer::updateBitfield(size_t index, int operation) {
int Peer::calculateUploadSpeed()
{
assert(res_);
- return res_->getPeerStat().calculateUploadSpeed();
+ return res_->getNetStat().calculateUploadSpeed();
}
int Peer::calculateDownloadSpeed()
{
assert(res_);
- return res_->getPeerStat().calculateDownloadSpeed();
+ return res_->getNetStat().calculateDownloadSpeed();
}
int64_t Peer::getSessionUploadLength() const