осталось малость пофиксить
This commit is contained in:
parent
2d2cd016c7
commit
75a6b87680
@ -78,7 +78,7 @@ namespace BusinessLogic.BusinessLogic
|
|||||||
|
|
||||||
public string TestInsertList(int num)
|
public string TestInsertList(int num)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return _routeStorage.TestInsertList(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string TestReadList(int num)
|
public string TestReadList(int num)
|
||||||
|
@ -19,31 +19,27 @@ namespace TransportGuide
|
|||||||
public FormTests(IRouteLogic routeLogic)//IUserLogic userLogic, ITopicLogic topicLogic, IMessageLogic messageLogic)
|
public FormTests(IRouteLogic routeLogic)//IUserLogic userLogic, ITopicLogic topicLogic, IMessageLogic messageLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
//_userLogic = userLogic;
|
|
||||||
//_topicLogic = topicLogic;
|
|
||||||
_routeLogic= routeLogic;
|
_routeLogic= routeLogic;
|
||||||
numericUpDownInsert.Minimum = 0;
|
numericUpDownInsert.Minimum = 1;
|
||||||
numericUpDownInsert.Maximum = 1000000;
|
numericUpDownInsert.Maximum = 1000000;
|
||||||
numericUpDownRead.Minimum = 0;
|
numericUpDownRead.Minimum = 1;
|
||||||
numericUpDownRead.Maximum = 1000000;
|
numericUpDownRead.Maximum = 1000000;
|
||||||
numericUpDownJoin.Minimum = 0;
|
numericUpDownJoin.Minimum = 1;
|
||||||
numericUpDownJoin.Maximum = 1000000;
|
numericUpDownJoin.Maximum = 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonInsertTest_Click(object sender, EventArgs e)
|
private void buttonInsertTest_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//try
|
try
|
||||||
//{
|
{
|
||||||
// var result = _messageLogic.TestInsertList(Convert.ToInt32(numericUpDownInsert.Value),
|
var result = _routeLogic.TestInsertList(Convert.ToInt32(numericUpDownInsert.Value));
|
||||||
// _userLogic.ReadList(null) ?? new(),
|
|
||||||
// _topicLogic.ReadList(null) ?? new());
|
|
||||||
|
|
||||||
// textBoxInsertTime.Text = result;
|
textBoxInsertTime.Text = result;
|
||||||
//}
|
}
|
||||||
//catch (Exception ex)
|
catch (Exception ex)
|
||||||
//{
|
{
|
||||||
// MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonReadTest_Click(object sender, EventArgs e)
|
private void buttonReadTest_Click(object sender, EventArgs e)
|
||||||
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using TransportGuideContracts.BindingModels;
|
using TransportGuideContracts.BindingModels;
|
||||||
@ -82,7 +83,53 @@ namespace TransportGuideDatabaseImplements.Implements
|
|||||||
|
|
||||||
public string TestInsertList(int num)
|
public string TestInsertList(int num)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var context = new TransportGuideDB();
|
||||||
|
Stopwatch stopwatch = new();
|
||||||
|
Random rnd = new Random();
|
||||||
|
long[] res = new long[num * 2];
|
||||||
|
List<TransportTypeViewModel> _types = context.TransportTypes.ToList().Select(x => x.GetViewModel).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < num; ++i)
|
||||||
|
{
|
||||||
|
int rndId = rnd.Next();
|
||||||
|
var model = new StopBindingModel
|
||||||
|
{
|
||||||
|
Id = rndId,
|
||||||
|
Name = "Stop" + rndId.ToString(),
|
||||||
|
};
|
||||||
|
context.Stops.Add(Stop.Create(model));
|
||||||
|
stopwatch.Start();
|
||||||
|
context.SaveChanges();
|
||||||
|
stopwatch.Stop();
|
||||||
|
res[i] = stopwatch.ElapsedMilliseconds;
|
||||||
|
}
|
||||||
|
List<StopViewModel> _stops = context.Stops.Select(x => x.GetViewModel).ToList();
|
||||||
|
|
||||||
|
for (int i = 0; i < num; ++i)
|
||||||
|
{
|
||||||
|
int rndId = rnd.Next();
|
||||||
|
var model = new RouteBindingModel
|
||||||
|
{
|
||||||
|
Id = rndId,
|
||||||
|
Name = "Route" + rndId.ToString(),
|
||||||
|
IP = "IP" + rndId.ToString(),
|
||||||
|
TransportTypeId = _types[rnd.Next(_types.Count)].Id
|
||||||
|
};
|
||||||
|
context.Routes.Add(Route.Create(context, model));
|
||||||
|
stopwatch.Start();
|
||||||
|
context.SaveChanges();
|
||||||
|
stopwatch.Stop();
|
||||||
|
res[i] = stopwatch.ElapsedMilliseconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
long sum = 0;
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
sum += res[i];
|
||||||
|
}
|
||||||
|
int result = Convert.ToInt32(sum / num);
|
||||||
|
return result.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string TestReadList(int num)
|
public string TestReadList(int num)
|
||||||
|
Loading…
Reference in New Issue
Block a user