-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmain.cc
More file actions
47 lines (40 loc) · 1.12 KB
/
main.cc
File metadata and controls
47 lines (40 loc) · 1.12 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
#include "sqlitetest.hpp"
#include <QCoreApplication>
#include <QSqlDatabase>
#include <thread>
void insertThread(const QString &brand)
{
SqliteTest test;
for (int i = 0; i < 1000; i++) {
test.insert(brand, i);
test.readLastRecord();
}
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
if (!QSqlDatabase::drivers().contains("QSQLITE")) {
qWarning() << "This demo needs the SQLITE driver";
return -1;
}
const QStringList brands{"Apple",
"Samsung",
"Xiaomi",
"Redmi",
"Oppo",
"Vivo",
"Realme",
"IQOO",
"OnePlus",
"Pixel"};
std::vector<std::thread> threads;
for (const auto &brand : std::as_const(brands)) {
threads.emplace_back(insertThread, brand);
}
for (auto &thread : threads) {
if (thread.joinable()) {
thread.join();
}
}
return 0;
}