This commit is contained in:
86
source/Plugins/AyaNova.PlugIn.PerfAdvisor/Advisor.cs
Normal file
86
source/Plugins/AyaNova.PlugIn.PerfAdvisor/Advisor.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Diagnostics;
|
||||
using GZTW.AyaNova.BLL;
|
||||
|
||||
namespace AyaNova.PlugIn.PerfAdvisor
|
||||
{
|
||||
public partial class Advisor : Form
|
||||
{
|
||||
public Advisor()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Advisor_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show(
|
||||
"Performance advisor will now test AyaNova base performance.\r\nThis may take some time.\r\n\r\nContinue?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning,
|
||||
MessageBoxDefaultButton.Button2)
|
||||
== DialogResult.Cancel)
|
||||
this.Close();
|
||||
List<PerfItem> list = new List<PerfItem>();
|
||||
Stopwatch sw = new Stopwatch();
|
||||
|
||||
//Base db retrieval
|
||||
int nBaseIterations = 50;
|
||||
long dbOverhead = 0;//this is the time it takes just to run a query (sort of)
|
||||
sw.Start();
|
||||
for (int x = 0; x < nBaseIterations; x++)
|
||||
{
|
||||
GZTW.AyaNova.BLL.Region.GetItem(GZTW.AyaNova.BLL.Region.DefaultRegionID);
|
||||
UserPickList.GetListOfOneSpecificUser(User.AdministratorID);
|
||||
}
|
||||
sw.Stop();
|
||||
dbOverhead=sw.ElapsedMilliseconds/(nBaseIterations*2);
|
||||
list.Add(new PerfItem("Base DB query overhead", dbOverhead , 1));
|
||||
sw.Reset();
|
||||
|
||||
//Clients
|
||||
sw.Start();
|
||||
ClientPickList cpl = ClientPickList.GetList();
|
||||
|
||||
sw.Stop();
|
||||
list.Add(new PerfItem("Client pick list", sw.ElapsedMilliseconds-dbOverhead, cpl.Count));
|
||||
sw.Reset();
|
||||
|
||||
//Parts
|
||||
sw.Start();
|
||||
PartPickList ppl = PartPickList.GetAllParts();
|
||||
sw.Stop();
|
||||
list.Add(new PerfItem("Part pick list", sw.ElapsedMilliseconds-dbOverhead, ppl.Count));
|
||||
sw.Reset();
|
||||
|
||||
//Units
|
||||
sw.Start();
|
||||
UnitPickList upl = UnitPickList.GetListOfAll();
|
||||
sw.Stop();
|
||||
list.Add(new PerfItem("Unit pick list", sw.ElapsedMilliseconds - dbOverhead, upl.Count));
|
||||
sw.Reset();
|
||||
|
||||
System.Text.StringBuilder sb=new StringBuilder();
|
||||
sb.Append("Results:\r\n");
|
||||
foreach (PerfItem p in list)
|
||||
{
|
||||
sb.Append(p.Test);
|
||||
sb.Append(": ");
|
||||
sb.Append(p.Milliseconds.ToString());
|
||||
sb.Append(" total milliseconds, ");
|
||||
sb.Append(p.MillisecondsAverage.ToString());
|
||||
sb.Append(" average milliseconds, ");
|
||||
sb.Append(p.Count.ToString());
|
||||
sb.Append(" count.\r\n");
|
||||
}
|
||||
|
||||
MessageBox.Show(sb.ToString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user