filter out meanless data.
This commit is contained in:
@@ -52,23 +52,26 @@ namespace Shadowsocks.Model
|
||||
public StatisticsRecord(string identifier, ICollection<int> inboundSpeedRecords, ICollection<int> outboundSpeedRecords, ICollection<int> latencyRecords)
|
||||
{
|
||||
ServerIdentifier = identifier;
|
||||
if (inboundSpeedRecords != null && inboundSpeedRecords.Any())
|
||||
var inbound = inboundSpeedRecords?.Where(s => s > 0).ToList();
|
||||
if (inbound != null && inbound.Any())
|
||||
{
|
||||
AverageInboundSpeed = (int) inboundSpeedRecords.Average();
|
||||
MinInboundSpeed = inboundSpeedRecords.Min();
|
||||
MaxInboundSpeed = inboundSpeedRecords.Max();
|
||||
AverageInboundSpeed = (int) inbound.Average();
|
||||
MinInboundSpeed = inbound.Min();
|
||||
MaxInboundSpeed = inbound.Max();
|
||||
}
|
||||
if (outboundSpeedRecords != null && outboundSpeedRecords.Any())
|
||||
var outbound = outboundSpeedRecords?.Where(s => s > 0).ToList();
|
||||
if (outbound!= null && outbound.Any())
|
||||
{
|
||||
AverageOutboundSpeed = (int) outboundSpeedRecords.Average();
|
||||
MinOutboundSpeed = outboundSpeedRecords.Min();
|
||||
MaxOutboundSpeed = outboundSpeedRecords.Max();
|
||||
AverageOutboundSpeed = (int) outbound.Average();
|
||||
MinOutboundSpeed = outbound.Min();
|
||||
MaxOutboundSpeed = outbound.Max();
|
||||
}
|
||||
if (latencyRecords != null && latencyRecords.Any())
|
||||
var latency = latencyRecords?.Where(s => s > 0).ToList();
|
||||
if (latency!= null && latency.Any())
|
||||
{
|
||||
AverageLatency = (int) latencyRecords.Average();
|
||||
MinLatency = latencyRecords.Min();
|
||||
MaxLatency = latencyRecords.Max();
|
||||
AverageLatency = (int) latency.Average();
|
||||
MinLatency = latency.Min();
|
||||
MaxLatency = latency.Max();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -125,9 +125,9 @@ namespace Shadowsocks.View
|
||||
dataGroup.First().Timestamp,
|
||||
Speed = dataGroup.Max(data => data.MaxInboundSpeed) ?? 0,
|
||||
Ping = (int) (dataGroup.Average(data => data.AverageResponse) ?? 0),
|
||||
PackageLossPercentage = (dataGroup.Average(data => data.PackageLoss) ?? 0) * 100
|
||||
PackageLossPercentage = (int) (dataGroup.Average(data => data.PackageLoss) ?? 0) * 100
|
||||
};
|
||||
foreach (var data in finalData)
|
||||
foreach (var data in finalData.Where(data => data.Speed != 0 || data.PackageLossPercentage != 0 || data.Ping != 0))
|
||||
{
|
||||
_dataTable.Rows.Add(data.Timestamp, data.Speed, data.PackageLossPercentage, data.Ping);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user