Browse Source

filter out meanless data.

tags/3.0
icylogic 8 years ago
parent
commit
8f175c481e
2 changed files with 17 additions and 14 deletions
  1. +15
    -12
      shadowsocks-csharp/Model/StatisticsRecord.cs
  2. +2
    -2
      shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs

+ 15
- 12
shadowsocks-csharp/Model/StatisticsRecord.cs View File

@@ -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();
}
}



+ 2
- 2
shadowsocks-csharp/View/StatisticsStrategyConfigurationForm.cs View File

@@ -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);
}


Loading…
Cancel
Save