-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.cpp
More file actions
73 lines (63 loc) · 2.41 KB
/
Copy pathMainWindow.cpp
File metadata and controls
73 lines (63 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "MainWindow.h"
#include "Test.h"
#include"BinarySearchTree.h"
#include "Set.h"
#include<functional>
#include<complex>
#include<chrono>
//#include"vld.h"
MainWindow::MainWindow(QWidget* parent)
: QWidget(parent)
{
ui.setupUi(this);
ui.widget1->setChart(&chrt);
chrt.setTitle("Graph");
size_t max_count = 1000000;
axisX.setRange(0, max_count - max_count / 100);
axisX.setTickCount(10);
axisX.setLabelFormat("%g");
axisX.setTitleText("N");
axisY.setRange(0, 10000);
axisY.setTickCount(11);
axisY.setLabelFormat("%g");
axisY.setTitleText("t, ns");
Set<int> set;
BinarySearchTree<int> int_bst;
for (size_t j = 0; j < max_count; j++)
{
if (j % (max_count / 100) == 0)
{
auto start = std::chrono::system_clock::now();
set.Add(j);
auto end = std::chrono::system_clock::now();
double curr_time_add = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
start = std::chrono::system_clock::now();
set.Has(j);
end = std::chrono::system_clock::now();
double curr_time_has = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
series_add.append(j, curr_time_add);
series_has.append(j, curr_time_has);
}
else
set.Add(j);
}
series_add.setName("Add");
series_has.setName("Set");
chrt.addSeries(&series_add);
chrt.setAxisX(&axisX, &series_add);
chrt.setAxisY(&axisY, &series_add);
chrt.addSeries(&series_has);
chrt.setAxisX(&axisX, &series_has);
chrt.setAxisY(&axisY, &series_has);
QObject::connect(ui.TestButton, SIGNAL(clicked()), this, SLOT(StartTest()));
}
void MainWindow::StartTest()
{
test_window.show();
test_window.ui.TestAddLable->setText(TestAdd() ? "<font color=\"green\">Success</font>" : "<font color=\"red\">Failure</font>");
test_window.ui.TestHasLable->setText(TestHas() ? "<font color=\"green\">Success</font>" : "<font color=\"red\">Failure</font>");
test_window.ui.TestDeleteLable->setText(TestDelete() ? "<font color=\"green\">Success</font>" : "<font color=\"red\">Failure</font>");
test_window.ui.TestUnionLable->setText(TestUnion() ? "<font color=\"green\">Success</font>" : "<font color=\"red\">Failure</font>");
test_window.ui.TestIntersectionLable->setText(TestIntersection() ? "<font color=\"green\">Success</font>" : "<font color=\"red\">Failure</font>");
test_window.ui.TestRelativeComplementLable->setText(TestRelativeComplement() ? "<font color=\"green\">Success</font>" : "<font color=\"red\">Failure</font>");
}