замеры времени на 3 сущности
This commit is contained in:
parent
be017f5d16
commit
59c749647d
@ -63,7 +63,7 @@ namespace DepartmentStaffDatabase
|
|||||||
{
|
{
|
||||||
using var conn = GetConnect();
|
using var conn = GetConnect();
|
||||||
conn.Open();
|
conn.Open();
|
||||||
using var cmd = new NpgsqlCommand($"SELECT * FROM department WHERE name = {departmentName}", conn);
|
using var cmd = new NpgsqlCommand($"SELECT * FROM department WHERE name = '{departmentName}'", conn);
|
||||||
using var reader = cmd.ExecuteReader();
|
using var reader = cmd.ExecuteReader();
|
||||||
if (reader.Read())
|
if (reader.Read())
|
||||||
{
|
{
|
||||||
@ -156,7 +156,7 @@ namespace DepartmentStaffDatabase
|
|||||||
{
|
{
|
||||||
using var conn = GetConnect();
|
using var conn = GetConnect();
|
||||||
conn.Open();
|
conn.Open();
|
||||||
using var cmd = new NpgsqlCommand($"SELECT * FROM position WHERE id = {positionName}", conn);
|
using var cmd = new NpgsqlCommand($"SELECT * FROM position WHERE name = '{positionName}'", conn);
|
||||||
using var reader = cmd.ExecuteReader();
|
using var reader = cmd.ExecuteReader();
|
||||||
if (reader.Read())
|
if (reader.Read())
|
||||||
{
|
{
|
||||||
@ -261,7 +261,7 @@ namespace DepartmentStaffDatabase
|
|||||||
{
|
{
|
||||||
using var conn = GetConnect();
|
using var conn = GetConnect();
|
||||||
conn.Open();
|
conn.Open();
|
||||||
using var cmd = new NpgsqlCommand($"SELECT * FROM employee WHERE id = {employeeName}", conn);
|
using var cmd = new NpgsqlCommand($"SELECT * FROM employee WHERE name = '{employeeName}'", conn);
|
||||||
using var reader = cmd.ExecuteReader();
|
using var reader = cmd.ExecuteReader();
|
||||||
if (reader.Read())
|
if (reader.Read())
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,15 @@
|
|||||||
buttonContracts = new Button();
|
buttonContracts = new Button();
|
||||||
buttonCourses = new Button();
|
buttonCourses = new Button();
|
||||||
buttonEmpCourse = new Button();
|
buttonEmpCourse = new Button();
|
||||||
|
buttonDepartmentsCreate = new Button();
|
||||||
|
buttonDepartmentsUpdate = new Button();
|
||||||
|
buttonDepartmentsDelete = new Button();
|
||||||
|
buttonPositionsDelete = new Button();
|
||||||
|
buttonPositionsUpdate = new Button();
|
||||||
|
buttonPositionsCreate = new Button();
|
||||||
|
buttonEmployeesDelete = new Button();
|
||||||
|
buttonEmployeesUpdate = new Button();
|
||||||
|
buttonEmployeesCreate = new Button();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// buttonDepartments
|
// buttonDepartments
|
||||||
@ -96,11 +105,110 @@
|
|||||||
buttonEmpCourse.UseVisualStyleBackColor = true;
|
buttonEmpCourse.UseVisualStyleBackColor = true;
|
||||||
buttonEmpCourse.Click += buttonEmployee_Courses_Click;
|
buttonEmpCourse.Click += buttonEmployee_Courses_Click;
|
||||||
//
|
//
|
||||||
|
// buttonDepartmentsCreate
|
||||||
|
//
|
||||||
|
buttonDepartmentsCreate.Location = new Point(159, 12);
|
||||||
|
buttonDepartmentsCreate.Name = "buttonDepartmentsCreate";
|
||||||
|
buttonDepartmentsCreate.Size = new Size(141, 44);
|
||||||
|
buttonDepartmentsCreate.TabIndex = 6;
|
||||||
|
buttonDepartmentsCreate.Text = "Создать 20 отделов";
|
||||||
|
buttonDepartmentsCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonDepartmentsCreate.Click += buttonDepartmentsCreate_Click;
|
||||||
|
//
|
||||||
|
// buttonDepartmentsUpdate
|
||||||
|
//
|
||||||
|
buttonDepartmentsUpdate.Location = new Point(306, 12);
|
||||||
|
buttonDepartmentsUpdate.Name = "buttonDepartmentsUpdate";
|
||||||
|
buttonDepartmentsUpdate.Size = new Size(141, 44);
|
||||||
|
buttonDepartmentsUpdate.TabIndex = 7;
|
||||||
|
buttonDepartmentsUpdate.Text = "Обновить 20 отделов";
|
||||||
|
buttonDepartmentsUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonDepartmentsUpdate.Click += buttonDepartmentsUpdate_Click;
|
||||||
|
//
|
||||||
|
// buttonDepartmentsDelete
|
||||||
|
//
|
||||||
|
buttonDepartmentsDelete.Location = new Point(453, 12);
|
||||||
|
buttonDepartmentsDelete.Name = "buttonDepartmentsDelete";
|
||||||
|
buttonDepartmentsDelete.Size = new Size(141, 44);
|
||||||
|
buttonDepartmentsDelete.TabIndex = 8;
|
||||||
|
buttonDepartmentsDelete.Text = "Удалить 20 отделов";
|
||||||
|
buttonDepartmentsDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDepartmentsDelete.Click += buttonDepartmentsDelete_Click;
|
||||||
|
//
|
||||||
|
// buttonPositionsDelete
|
||||||
|
//
|
||||||
|
buttonPositionsDelete.Location = new Point(453, 72);
|
||||||
|
buttonPositionsDelete.Name = "buttonPositionsDelete";
|
||||||
|
buttonPositionsDelete.Size = new Size(141, 44);
|
||||||
|
buttonPositionsDelete.TabIndex = 11;
|
||||||
|
buttonPositionsDelete.Text = "Удалить 50 должностей";
|
||||||
|
buttonPositionsDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonPositionsDelete.Click += buttonPositionsDelete_Click;
|
||||||
|
//
|
||||||
|
// buttonPositionsUpdate
|
||||||
|
//
|
||||||
|
buttonPositionsUpdate.Location = new Point(306, 72);
|
||||||
|
buttonPositionsUpdate.Name = "buttonPositionsUpdate";
|
||||||
|
buttonPositionsUpdate.Size = new Size(141, 44);
|
||||||
|
buttonPositionsUpdate.TabIndex = 10;
|
||||||
|
buttonPositionsUpdate.Text = "Обновить 50 должностей";
|
||||||
|
buttonPositionsUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonPositionsUpdate.Click += buttonPositionsUpdate_Click;
|
||||||
|
//
|
||||||
|
// buttonPositionsCreate
|
||||||
|
//
|
||||||
|
buttonPositionsCreate.Location = new Point(159, 72);
|
||||||
|
buttonPositionsCreate.Name = "buttonPositionsCreate";
|
||||||
|
buttonPositionsCreate.Size = new Size(141, 44);
|
||||||
|
buttonPositionsCreate.TabIndex = 9;
|
||||||
|
buttonPositionsCreate.Text = "Создать 50 должностей";
|
||||||
|
buttonPositionsCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonPositionsCreate.Click += buttonPositionsCreate_Click;
|
||||||
|
//
|
||||||
|
// buttonEmployeesDelete
|
||||||
|
//
|
||||||
|
buttonEmployeesDelete.Location = new Point(453, 131);
|
||||||
|
buttonEmployeesDelete.Name = "buttonEmployeesDelete";
|
||||||
|
buttonEmployeesDelete.Size = new Size(141, 44);
|
||||||
|
buttonEmployeesDelete.TabIndex = 14;
|
||||||
|
buttonEmployeesDelete.Text = "Удалить 200 работников";
|
||||||
|
buttonEmployeesDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonEmployeesDelete.Click += buttonEmployeesDelete_Click;
|
||||||
|
//
|
||||||
|
// buttonEmployeesUpdate
|
||||||
|
//
|
||||||
|
buttonEmployeesUpdate.Location = new Point(306, 131);
|
||||||
|
buttonEmployeesUpdate.Name = "buttonEmployeesUpdate";
|
||||||
|
buttonEmployeesUpdate.Size = new Size(141, 44);
|
||||||
|
buttonEmployeesUpdate.TabIndex = 13;
|
||||||
|
buttonEmployeesUpdate.Text = "Обновить 200 работников";
|
||||||
|
buttonEmployeesUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonEmployeesUpdate.Click += buttonEmployeesUpdate_Click;
|
||||||
|
//
|
||||||
|
// buttonEmployeesCreate
|
||||||
|
//
|
||||||
|
buttonEmployeesCreate.Location = new Point(159, 131);
|
||||||
|
buttonEmployeesCreate.Name = "buttonEmployeesCreate";
|
||||||
|
buttonEmployeesCreate.Size = new Size(141, 44);
|
||||||
|
buttonEmployeesCreate.TabIndex = 12;
|
||||||
|
buttonEmployeesCreate.Text = "Создать 200 работников";
|
||||||
|
buttonEmployeesCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonEmployeesCreate.Click += buttonEmployeesCreate_Click;
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 376);
|
||||||
|
Controls.Add(buttonEmployeesDelete);
|
||||||
|
Controls.Add(buttonEmployeesUpdate);
|
||||||
|
Controls.Add(buttonEmployeesCreate);
|
||||||
|
Controls.Add(buttonPositionsDelete);
|
||||||
|
Controls.Add(buttonPositionsUpdate);
|
||||||
|
Controls.Add(buttonPositionsCreate);
|
||||||
|
Controls.Add(buttonDepartmentsDelete);
|
||||||
|
Controls.Add(buttonDepartmentsUpdate);
|
||||||
|
Controls.Add(buttonDepartmentsCreate);
|
||||||
Controls.Add(buttonEmpCourse);
|
Controls.Add(buttonEmpCourse);
|
||||||
Controls.Add(buttonCourses);
|
Controls.Add(buttonCourses);
|
||||||
Controls.Add(buttonContracts);
|
Controls.Add(buttonContracts);
|
||||||
@ -120,5 +228,14 @@
|
|||||||
private Button buttonContracts;
|
private Button buttonContracts;
|
||||||
private Button buttonCourses;
|
private Button buttonCourses;
|
||||||
private Button buttonEmpCourse;
|
private Button buttonEmpCourse;
|
||||||
|
private Button buttonDepartmentsCreate;
|
||||||
|
private Button buttonDepartmentsUpdate;
|
||||||
|
private Button buttonDepartmentsDelete;
|
||||||
|
private Button buttonPositionsDelete;
|
||||||
|
private Button buttonPositionsUpdate;
|
||||||
|
private Button buttonPositionsCreate;
|
||||||
|
private Button buttonEmployeesDelete;
|
||||||
|
private Button buttonEmployeesUpdate;
|
||||||
|
private Button buttonEmployeesCreate;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,6 +8,8 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
namespace DepartmentStaffView
|
namespace DepartmentStaffView
|
||||||
{
|
{
|
||||||
@ -67,5 +69,183 @@ namespace DepartmentStaffView
|
|||||||
form.Show();
|
form.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buttonDepartmentsCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string name = "departmentName";
|
||||||
|
string head = "departmentHead";
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
db.CreateDepartment(new()
|
||||||
|
{
|
||||||
|
DepartmentName = $"{name}{i}",
|
||||||
|
Head = $"{head}{i}",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
DateTime end = DateTime.Now;
|
||||||
|
MessageBox.Show("Добавлено 20 отделов за " + (end - start).Milliseconds.ToString() + " миллисекунд");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDepartmentsUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Department dep = db.GetDepartment("departmentName0");
|
||||||
|
int currentId = dep.Id;
|
||||||
|
|
||||||
|
string name = "new_departmentName";
|
||||||
|
string head = "new_departmentHead";
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
db.UpdateDepartment(new()
|
||||||
|
{
|
||||||
|
Id = currentId + i,
|
||||||
|
DepartmentName = $"{name}{i}",
|
||||||
|
Head = $"{head}{i}",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
DateTime end = DateTime.Now;
|
||||||
|
MessageBox.Show("Обновлено 20 отделов за " + (end - start).Milliseconds.ToString() + " миллисекунд");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDepartmentsDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Department dep = db.GetDepartment("new_departmentName0");
|
||||||
|
int currentId = dep.Id;
|
||||||
|
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
db.DeleteDepartment(currentId + i);
|
||||||
|
}
|
||||||
|
DateTime end = DateTime.Now;
|
||||||
|
MessageBox.Show("Удалено 20 отделов за " + (end - start).Milliseconds.ToString() + " миллисекунд");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonPositionsCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string name = "positionName";
|
||||||
|
double salary = 52.69;
|
||||||
|
int depId = 2;
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 0; i < 50; i++)
|
||||||
|
{
|
||||||
|
db.CreatePosition(new()
|
||||||
|
{
|
||||||
|
PositionName = $"{name}{i}",
|
||||||
|
Salary = salary,
|
||||||
|
DepartmentId = depId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
DateTime end = DateTime.Now;
|
||||||
|
MessageBox.Show("Добавлено 50 должностей за " + (end - start).Milliseconds.ToString() + " миллисекунд");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonPositionsUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Position pos = db.GetPosition("positionName0");
|
||||||
|
int currentId = pos.Id;
|
||||||
|
|
||||||
|
string name = "new_positionName";
|
||||||
|
double salary = 52.69;
|
||||||
|
int depId = 2;
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 0; i < 50; i++)
|
||||||
|
{
|
||||||
|
db.UpdatePosition(new()
|
||||||
|
{
|
||||||
|
Id = currentId + i,
|
||||||
|
PositionName = $"{name}{i}",
|
||||||
|
Salary = salary,
|
||||||
|
DepartmentId = depId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
DateTime end = DateTime.Now;
|
||||||
|
MessageBox.Show("Обновлено 50 должностей за " + (end - start).Milliseconds.ToString() + " миллисекунд");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonPositionsDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Position pos = db.GetPosition("new_positionName0");
|
||||||
|
int currentId = pos.Id;
|
||||||
|
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 0; i < 50; i++)
|
||||||
|
{
|
||||||
|
db.DeletePosition(currentId + i);
|
||||||
|
}
|
||||||
|
DateTime end = DateTime.Now;
|
||||||
|
MessageBox.Show("Удалено 50 должностей за " + (end - start).Milliseconds.ToString() + " миллисекунд");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonEmployeesCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string name = "employeeName";
|
||||||
|
DateTime birthdate = DateTime.Now;
|
||||||
|
string address = "address";
|
||||||
|
string email = "email";
|
||||||
|
string phone = "phone";
|
||||||
|
int posId = 1;
|
||||||
|
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 0; i < 200; i++)
|
||||||
|
{
|
||||||
|
db.CreateEmployee(new()
|
||||||
|
{
|
||||||
|
EmployeeName = $"{name}{i}",
|
||||||
|
Birthdate = birthdate,
|
||||||
|
Address = address,
|
||||||
|
PhoneNumber = phone,
|
||||||
|
Email = email,
|
||||||
|
PositionId = posId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
DateTime end = DateTime.Now;
|
||||||
|
MessageBox.Show("Добавлено 200 работников за " + (end - start).Milliseconds.ToString() + " миллисекунд");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonEmployeesUpdate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Employee emp = db.GetEmployee("employeeName0");
|
||||||
|
int currentId = emp.Id;
|
||||||
|
|
||||||
|
string name = "new_employeeName";
|
||||||
|
DateTime birthdate = DateTime.Now;
|
||||||
|
string address = "address";
|
||||||
|
string email = "email";
|
||||||
|
string phone = "phone";
|
||||||
|
int posId = 1;
|
||||||
|
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 0; i < 200; i++)
|
||||||
|
{
|
||||||
|
db.UpdateEmployee(new()
|
||||||
|
{
|
||||||
|
Id = currentId + i,
|
||||||
|
EmployeeName = $"{name}{i}",
|
||||||
|
Birthdate = birthdate,
|
||||||
|
Address = address,
|
||||||
|
PhoneNumber = phone,
|
||||||
|
Email = email,
|
||||||
|
PositionId = posId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
DateTime end = DateTime.Now;
|
||||||
|
MessageBox.Show("Обновлено 200 работников за " + (end - start).Milliseconds.ToString() + " миллисекунд");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonEmployeesDelete_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Employee emp = db.GetEmployee("new_employeeName0");
|
||||||
|
int currentId = emp.Id;
|
||||||
|
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
for (int i = 0; i < 200; i++)
|
||||||
|
{
|
||||||
|
db.DeleteEmployee(currentId + i);
|
||||||
|
}
|
||||||
|
DateTime end = DateTime.Now;
|
||||||
|
MessageBox.Show("Удалено 200 работников за " + (end - start).Milliseconds.ToString() + " миллисекунд");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user