Author: alanmc
Date: 2008-02-17 19:10:06 -0500 (Sun, 17 Feb 2008)
New Revision: 96019
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/ClientEngine.cs
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ChokeUnchokeManager.cs
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ConnectionMonitor.cs
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/PieceManager.cs
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/TorrentManager.cs
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Settings/TorrentSettings.cs
trunk/bitsharp/src/SampleClient/main.cs
Log:
Everything is in bytes/second now... or should be anyway.
Modified: trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/ClientEngine.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/ClientEngine.cs
2008-02-18 00:01:54 UTC (rev 96018)
+++ trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/ClientEngine.cs
2008-02-18 00:10:06 UTC (rev 96019)
@@ -372,27 +372,27 @@
/// <summary>
- /// Returns the combined download speed of all active torrents
+ /// Returns the combined download speed of all active torrents in
bytes/sec
/// </summary>
- public double TotalDownloadSpeed
+ public int TotalDownloadSpeed
{
get
{
using (new ReaderLock(torrentsLock))
- return Toolbox.Accumulate<TorrentManager>(torrents,
delegate(TorrentManager m) { return (int)m.Monitor.DownloadSpeed; });
+ return Toolbox.Accumulate<TorrentManager>(torrents,
delegate(TorrentManager m) { return m.Monitor.DownloadSpeed; });
}
}
/// <summary>
- /// Returns the combined upload speed of all active torrents
+ /// Returns the combined upload speed of all active torrents in
bytes/sec
/// </summary>
- public double TotalUploadSpeed
+ public int TotalUploadSpeed
{
get
{
using (new ReaderLock(torrentsLock))
- return Toolbox.Accumulate<TorrentManager>(torrents,
delegate(TorrentManager m) { return (int)m.Monitor.UploadSpeed; });
+ return Toolbox.Accumulate<TorrentManager>(torrents,
delegate(TorrentManager m) { return m.Monitor.UploadSpeed; });
}
}
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ChokeUnchokeManager.cs
===================================================================
---
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ChokeUnchokeManager.cs
2008-02-18 00:01:54 UTC (rev 96018)
+++
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ChokeUnchokeManager.cs
2008-02-18 00:10:06 UTC (rev 96019)
@@ -310,7 +310,7 @@
//Calculate the latest up/downloadrate
connectedPeer.Connection.LastReviewUploadRate
= (connectedPeer.Connection.Monitor.DataBytesUploaded -
connectedPeer.Connection.BytesUploadedAtLastReview) / timeSinceLastReview;
connectedPeer.Connection.LastReviewDownloadRate =
Math.Max((connectedPeer.Connection.Monitor.DataBytesDownloaded -
connectedPeer.Connection.BytesDownloadedAtLastReview) / timeSinceLastReview,
-
connectedPeer.Connection.Monitor.DownloadSpeed * 1000);
+
connectedPeer.Connection.Monitor.DownloadSpeed);
}
else if (connectedPeer.Connection.IsInterested)
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ConnectionMonitor.cs
===================================================================
---
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ConnectionMonitor.cs
2008-02-18 00:01:54 UTC (rev 96018)
+++
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ConnectionMonitor.cs
2008-02-18 00:10:06 UTC (rev 96019)
@@ -45,17 +45,17 @@
private long dataBytesDownloaded;
private long dataBytesUploaded;
- private double downloadSpeed;
+ private int downloadSpeed;
private int downloadSpeedIndex;
- private double[] downloadSpeeds;
+ private int[] downloadSpeeds;
private int lastUpdateTime;
private long protocolBytesDownloaded;
private long protocolBytesUploaded;
private int tempSentCount;
private int tempRecvCount;
- private double uploadSpeed;
+ private int uploadSpeed;
private int uploadSpeedIndex;
- private double[] uploadSpeeds;
+ private int[] uploadSpeeds;
#endregion Member Variables
@@ -67,7 +67,7 @@
/// </summary>
public long DataBytesDownloaded
{
- get { return this.dataBytesDownloaded / 1024; }
+ get { return this.dataBytesDownloaded; }
}
@@ -76,17 +76,17 @@
/// </summary>
public long DataBytesUploaded
{
- get { return this.dataBytesUploaded / 1024; }
+ get { return this.dataBytesUploaded; }
}
/// <summary>
- /// The current average download speed in kB/sec
+ /// The current average download speed in bytes/sec
/// </summary>
/// <returns></returns>
- public double DownloadSpeed
+ public int DownloadSpeed
{
- get { return this.downloadSpeed / 1024.0; }
+ get { return this.downloadSpeed; }
}
@@ -109,12 +109,12 @@
/// <summary>
- /// The current average upload speed in kB/sec
+ /// The current average upload speed in bytes/sec
/// </summary>
/// <returns></returns>
- public double UploadSpeed
+ public int UploadSpeed
{
- get { return this.uploadSpeed / 1024.0; }
+ get { return this.uploadSpeed; }
}
#endregion Public Properties
@@ -127,8 +127,8 @@
internal ConnectionMonitor()
{
this.lastUpdateTime = Environment.TickCount;
- this.uploadSpeeds = new double[ArraySize];
- this.downloadSpeeds = new double[ArraySize];
+ this.uploadSpeeds = new int[ArraySize];
+ this.downloadSpeeds = new int[ArraySize];
}
#endregion
@@ -213,7 +213,7 @@
lock (this.uploadSpeeds)
{
int count = 0;
- double total = 0;
+ int total = 0;
int currentTime = Environment.TickCount;
// Find how many miliseconds have passed since the last
update and the current tick count
@@ -231,8 +231,8 @@
// Take the amount of bytes sent since the last tick and
divide it by the number of seconds
// since the last tick. This gives the calculated
bytes/second transfer rate.
// difference is in miliseconds, so divide by 1000 to get
it in seconds
- this.downloadSpeeds[this.downloadSpeedIndex++] =
tempRecvCount / (difference / 1000.0);
- this.uploadSpeeds[this.uploadSpeedIndex++] = tempSentCount
/ (difference / 1000.0);
+ this.downloadSpeeds[this.downloadSpeedIndex++] =
(int)(tempRecvCount / (difference / 1000.0));
+ this.uploadSpeeds[this.uploadSpeedIndex++] =
(int)(tempSentCount / (difference / 1000.0));
// If we've gone over the array bounds, reset to the first
index
// to start overwriting the old values
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/PieceManager.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/PieceManager.cs
2008-02-18 00:01:54 UTC (rev 96018)
+++ trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/PieceManager.cs
2008-02-18 00:10:06 UTC (rev 96019)
@@ -107,8 +107,8 @@
RequestMessage msg;
// If someone can upload to us fast, queue more pieces off them.
But no more than 100 blocks.
- int maxRequests = PieceManager.NormalRequestAmount +
(int)(id.Connection.Monitor.DownloadSpeed / BonusRequestPerKb);
- maxRequests = maxRequests > 100 ? 100 : maxRequests;
+ int maxRequests = PieceManager.NormalRequestAmount +
(int)(id.Connection.Monitor.DownloadSpeed / 1024.0 / BonusRequestPerKb);
+ maxRequests = maxRequests > 50 ? 50 : maxRequests;
if (id.Connection.AmRequestingPiecesCount >= maxRequests)
return false;
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/TorrentManager.cs
===================================================================
---
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/TorrentManager.cs
2008-02-18 00:01:54 UTC (rev 96018)
+++
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/TorrentManager.cs
2008-02-18 00:10:06 UTC (rev 96019)
@@ -655,10 +655,10 @@
}
if (counter % (1000 / ClientEngine.TickLength) == 0)
-
this.rateLimiter.UpdateDownloadChunks((int)(this.settings.MaxDownloadSpeed *
1024 * 1.1),
-
(int)(this.settings.MaxUploadSpeed * 1024 * 1.1),
-
(int)(this.monitor.DownloadSpeed * 1024),
-
(int)(this.monitor.UploadSpeed * 1024));
+
this.rateLimiter.UpdateDownloadChunks((int)(this.settings.MaxDownloadSpeed *
1.1),
+
(int)(this.settings.MaxUploadSpeed * 1.1),
+
(this.monitor.DownloadSpeed),
+
(this.monitor.UploadSpeed));
}
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Settings/TorrentSettings.cs
===================================================================
---
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Settings/TorrentSettings.cs
2008-02-18 00:01:54 UTC (rev 96018)
+++
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Settings/TorrentSettings.cs
2008-02-18 00:10:06 UTC (rev 96019)
@@ -52,7 +52,7 @@
/// <summary>
- /// The maximum download speed for the torrent in kB/sec
+ /// The maximum download speed for the torrent in bytes/sec
/// </summary>
public int MaxDownloadSpeed
{
@@ -63,7 +63,7 @@
/// <summary>
- /// The maximum upload speed for the torrent in kB/sec
+ /// The maximum upload speed for the torrent in bytes/sec
/// </summary>
public int MaxUploadSpeed
{
Modified: trunk/bitsharp/src/SampleClient/main.cs
===================================================================
--- trunk/bitsharp/src/SampleClient/main.cs 2008-02-18 00:01:54 UTC (rev
96018)
+++ trunk/bitsharp/src/SampleClient/main.cs 2008-02-18 00:10:06 UTC (rev
96019)
@@ -176,10 +176,10 @@
sb.Remove(0, sb.Length);
AppendFormat(sb, "Torrent:
{0}", manager.Torrent.Name);
AppendFormat(sb, "Progress: {0:0.00}",
manager.Progress);
- AppendFormat(sb, "Download
Speed: {0:0.00} kB/s", manager.Monitor.DownloadSpeed);
- AppendFormat(sb, "Upload Speed:
{0:0.00} kB/s", manager.Monitor.UploadSpeed);
- AppendFormat(sb, "Total
Downloaded: {0:0.00} MB", manager.Monitor.DataBytesDownloaded / (1024.0));
- AppendFormat(sb, "Total
Uploaded: {0:0.00} MB", manager.Monitor.DataBytesUploaded / (1024.0));
+ AppendFormat(sb, "Download
Speed: {0:0.00} kB/s", manager.Monitor.DownloadSpeed / 1024.0);
+ AppendFormat(sb, "Upload Speed:
{0:0.00} kB/s", manager.Monitor.UploadSpeed / 1024.0);
+ AppendFormat(sb, "Total
Downloaded: {0:0.00} MB", manager.Monitor.DataBytesDownloaded / (1024.0 *
1024.0));
+ AppendFormat(sb, "Total
Uploaded: {0:0.00} MB", manager.Monitor.DataBytesUploaded / (1024.0 *
1024.0));
AppendFormat(sb, "Read Rate:
{0:0.00} kB/s", engine.DiskManager.ReadRate);
AppendFormat(sb, "Write Rate:
{0:0.00} kB/s", engine.DiskManager.WriteRate);
AppendFormat(sb, "Total Read:
{0:0.00} kB", engine.DiskManager.TotalRead);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches