mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-06 17:25:24 +08:00
qt 6.5.1 original
This commit is contained in:
@ -0,0 +1,13 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## tst_bench_qthreadstorage Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_benchmark(tst_bench_qthreadstorage
|
||||
SOURCES
|
||||
tst_bench_qthreadstorage.cpp
|
||||
LIBRARIES
|
||||
Qt::Test
|
||||
)
|
@ -0,0 +1,85 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <qtest.h>
|
||||
#include <QtCore>
|
||||
|
||||
QThreadStorage<int *> dummy[8];
|
||||
|
||||
QThreadStorage<QString *> tls1;
|
||||
|
||||
class tst_QThreadStorage : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tst_QThreadStorage();
|
||||
virtual ~tst_QThreadStorage();
|
||||
|
||||
public slots:
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
private slots:
|
||||
void construct();
|
||||
void get();
|
||||
void set();
|
||||
};
|
||||
|
||||
tst_QThreadStorage::tst_QThreadStorage()
|
||||
{
|
||||
}
|
||||
|
||||
tst_QThreadStorage::~tst_QThreadStorage()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QThreadStorage::init()
|
||||
{
|
||||
dummy[1].setLocalData(new int(5));
|
||||
dummy[2].setLocalData(new int(4));
|
||||
dummy[3].setLocalData(new int(3));
|
||||
tls1.setLocalData(new QString());
|
||||
}
|
||||
|
||||
void tst_QThreadStorage::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QThreadStorage::construct()
|
||||
{
|
||||
QBENCHMARK {
|
||||
QThreadStorage<int *> ts;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tst_QThreadStorage::get()
|
||||
{
|
||||
QThreadStorage<int *> ts;
|
||||
ts.setLocalData(new int(45));
|
||||
|
||||
int count = 0;
|
||||
QBENCHMARK {
|
||||
int *i = ts.localData();
|
||||
count += *i;
|
||||
}
|
||||
QVERIFY(count > 0);
|
||||
ts.setLocalData(0);
|
||||
}
|
||||
|
||||
void tst_QThreadStorage::set()
|
||||
{
|
||||
QThreadStorage<int *> ts;
|
||||
|
||||
int count = 0;
|
||||
QBENCHMARK {
|
||||
ts.setLocalData(new int(count));
|
||||
count++;
|
||||
}
|
||||
ts.setLocalData(0);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QThreadStorage)
|
||||
|
||||
#include "tst_bench_qthreadstorage.moc"
|
Reference in New Issue
Block a user