Improve performance and reduce memory consumption drastically
This commit is contained in:
parent
6d75e6a381
commit
c29d11efc1
@ -56,11 +56,10 @@ namespace ISPChk.Controllers
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
var startTime = DateTimeOffset.FromUnixTimeMilliseconds(start);
|
var startTime = DateTimeOffset.FromUnixTimeMilliseconds(start).DateTime;
|
||||||
var endTime = DateTimeOffset.FromUnixTimeMilliseconds(end);
|
var endTime = DateTimeOffset.FromUnixTimeMilliseconds(end).DateTime;
|
||||||
|
|
||||||
_context.Entry(host).Collection(h => h.PingItems).Load();
|
var pis = _context.Entry(host).Collection(h => h.PingItems).Query().Where(p => p.Date > startTime).ToList();
|
||||||
var pis = host.PingItems.Where(p => p.Date > startTime).ToList();
|
|
||||||
|
|
||||||
return pis;
|
return pis;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace ISPChk.Models
|
|||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public long PingId { get; set; }
|
public long PingId { get; set; }
|
||||||
public DateTimeOffset Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
public float Min { get; set; }
|
public float Min { get; set; }
|
||||||
public float Max { get; set; }
|
public float Max { get; set; }
|
||||||
public float Avg { get; set; }
|
public float Avg { get; set; }
|
||||||
|
@ -23,7 +23,7 @@ namespace ISPChk
|
|||||||
|
|
||||||
public async void LoadHostsFromDatabase()
|
public async void LoadHostsFromDatabase()
|
||||||
{
|
{
|
||||||
List<Host> hosts = await _context.Hosts.Include(host => host.PingItems).ToListAsync();
|
List<Host> hosts = await _context.Hosts.ToListAsync();
|
||||||
foreach (Host host in hosts)
|
foreach (Host host in hosts)
|
||||||
{
|
{
|
||||||
AddHost(host);
|
AddHost(host);
|
||||||
@ -47,7 +47,7 @@ namespace ISPChk
|
|||||||
// Do not use the outer context, not threadsafe?
|
// Do not use the outer context, not threadsafe?
|
||||||
var ctx = CreateDbContext();
|
var ctx = CreateDbContext();
|
||||||
var h = await ctx.Hosts.FindAsync(host.HostId);
|
var h = await ctx.Hosts.FindAsync(host.HostId);
|
||||||
ctx.Entry(h).Collection(hst => hst.PingItems).Load();
|
ctx.Entry(h).Collection(hst => hst.PingItems).Query().FirstOrDefault();
|
||||||
|
|
||||||
IPAddress pingAddress;
|
IPAddress pingAddress;
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ namespace ISPChk
|
|||||||
if (min > timeout)
|
if (min > timeout)
|
||||||
min = 0;
|
min = 0;
|
||||||
System.Diagnostics.Debug.WriteLine(h.HostName+": "+"min:" + min + " max:" + max + " avg:" + avg);
|
System.Diagnostics.Debug.WriteLine(h.HostName+": "+"min:" + min + " max:" + max + " avg:" + avg);
|
||||||
PingItem pi = new PingItem { Date = DateTimeOffset.UtcNow, Min = min, Max = max, Avg = avg, Failures = failures };
|
PingItem pi = new PingItem { Date = DateTimeOffset.UtcNow.DateTime, Min = min, Max = max, Avg = avg, Failures = failures };
|
||||||
h.PingItems.Add(pi);
|
h.PingItems.Add(pi);
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
// Throttle if everything is ok
|
// Throttle if everything is ok
|
||||||
|
@ -67,14 +67,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm">
|
|
||||||
</div>
|
|
||||||
<div class="col-sm">
|
<div class="col-sm">
|
||||||
<div id="chartContainerButtons">
|
<div id="chartContainerButtons">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="chartContainer" class="row">
|
<div id="chartContainer" class="row">
|
||||||
|
|
||||||
|
@ -128,8 +128,8 @@ async function updateGraphs() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'fail',
|
label: 'fail',
|
||||||
type: 'bar',
|
//type: 'bar',
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.6)',
|
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
||||||
borderColor: 'rgb(0, 0, 0)',
|
borderColor: 'rgb(0, 0, 0)',
|
||||||
yAxisID: "y-loss",
|
yAxisID: "y-loss",
|
||||||
data: val.failures
|
data: val.failures
|
||||||
|
Loading…
x
Reference in New Issue
Block a user