File indexing completed on 2024-05-12 04:02:23

0001 /* -*- C++ -*-
0002     This file is part of ThreadWeaver.
0003 
0004     SPDX-FileCopyrightText: 2005-2014 Mirko Boehm <mirko@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #include <QTemporaryDir>
0010 #include <QTest>
0011 
0012 #include <ThreadWeaver/ThreadWeaver>
0013 
0014 #include "Benchmark.h"
0015 #include "Model.h"
0016 
0017 using namespace std;
0018 using namespace ThreadWeaver;
0019 
0020 void Benchmark::processThumbNailsAsBenchmarkInLoop()
0021 {
0022     const QFileInfoList files = images();
0023     { // create a block to avoid adding the time needed to remove the temporary
0024         // directory from the file system to the measured time:
0025         QTemporaryDir temp;
0026         QBENCHMARK {
0027             Model model;
0028             model.prepareConversions(files, temp.path());
0029             QVERIFY(model.computeThumbNailsBlockingInLoop());
0030         }
0031     }
0032 }
0033 
0034 void Benchmark::processThumbNailsAsBenchmarkWithThreadWeaver()
0035 {
0036     const QFileInfoList files = images();
0037     { // create a block to avoid adding the time needed to remove the temporary
0038         // directory from the file system to the measured time:
0039         QTemporaryDir temp;
0040         QBENCHMARK {
0041             Model model;
0042             model.prepareConversions(files, temp.path());
0043             QVERIFY(model.computeThumbNailsBlockingConcurrent());
0044         }
0045     }
0046 }
0047 
0048 const QFileInfoList Benchmark::images()
0049 {
0050     const QDir dir = QDir(QLatin1String("/usr/share/backgrounds"));
0051     return dir.entryInfoList(QStringList() << QLatin1String("*.jpg"));
0052 }
0053 
0054 #include "moc_Benchmark.cpp"