1/* -*- C++ -*-
2 This file is part of ThreadWeaver.
3
4 SPDX-FileCopyrightText: 2005-2014 Mirko Boehm <mirko@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#include <QTemporaryDir>
10#include <QTest>
11
12#include <ThreadWeaver/ThreadWeaver>
13
14#include "Benchmark.h"
15#include "Model.h"
16
17using namespace std;
18using namespace ThreadWeaver;
19
20void Benchmark::processThumbNailsAsBenchmarkInLoop()
21{
22 const QFileInfoList files = images();
23 { // create a block to avoid adding the time needed to remove the temporary
24 // directory from the file system to the measured time:
25 QTemporaryDir temp;
26 QBENCHMARK {
27 Model model;
28 model.prepareConversions(filenames: files, outputDirectory: temp.path());
29 QVERIFY(model.computeThumbNailsBlockingInLoop());
30 }
31 }
32}
33
34void Benchmark::processThumbNailsAsBenchmarkWithThreadWeaver()
35{
36 const QFileInfoList files = images();
37 { // create a block to avoid adding the time needed to remove the temporary
38 // directory from the file system to the measured time:
39 QTemporaryDir temp;
40 QBENCHMARK {
41 Model model;
42 model.prepareConversions(filenames: files, outputDirectory: temp.path());
43 QVERIFY(model.computeThumbNailsBlockingConcurrent());
44 }
45 }
46}
47
48const QFileInfoList Benchmark::images()
49{
50 const QDir dir = QDir(QLatin1String("/usr/share/backgrounds"));
51 return dir.entryInfoList(nameFilters: QStringList() << QLatin1String("*.jpg"));
52}
53
54#include "moc_Benchmark.cpp"
55

source code of threadweaver/examples/ThumbNailer/Benchmark.cpp