File indexing completed on 2024-05-19 05:47:32

0001 /*
0002    This file is part of the KDE Baloo project.
0003  * Copyright (C) 2015  Vishesh Handa <vhanda@kde.org>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Lesser General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2.1 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Lesser General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Lesser General Public
0016  * License along with this library; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0018  *
0019  */
0020 
0021 #include "database.h"
0022 #include "transaction.h"
0023 #include "document.h"
0024 
0025 #include <QTest>
0026 #include <QTemporaryDir>
0027 
0028 using namespace Baloo;
0029 
0030 class DatabaseBenchmark : public QObject
0031 {
0032     Q_OBJECT
0033 private Q_SLOTS:
0034     void test();
0035 };
0036 
0037 void DatabaseBenchmark::test()
0038 {
0039     /*
0040     QTime timer;
0041     timer.start();
0042 
0043     QTemporaryDir dir;
0044     Database db(dir.path());
0045     db.open();
0046     Transaction tr(db, Transaction::ReadWrite);
0047 
0048     QDateTime dt = QDateTime::currentDateTime();
0049     uint i = 1;
0050     QBENCHMARK {
0051         Document doc;
0052         doc.setId(i++);
0053         doc.addTerm("Mplain/text");
0054 
0055         QByteArray fileName = "file" + QByteArray::number(i);
0056         doc.addTerm(fileName);
0057         doc.addFileNameTerm("F" + fileName);
0058 
0059         QDateTime mod = dt.addDays(-1 * i);
0060         const QByteArray dtm = mod.toString(Qt::ISODate).toUtf8();
0061 
0062         doc.addBoolTerm(QByteArray("DT_M") + dtm);
0063         doc.addBoolTerm(QByteArray("DT_MY") + QByteArray::number(mod.date().year()));
0064         doc.addBoolTerm(QByteArray("DT_MM") + QByteArray::number(mod.date().month()));
0065         doc.addBoolTerm(QByteArray("DT_MD") + QByteArray::number(mod.date().day()));
0066 
0067         doc.setMTime(1);
0068         doc.setCTime(2);
0069 
0070         tr.addDocument(doc);
0071     }
0072     tr.commit();
0073 
0074     qDebug() << i << timer.elapsed();
0075     */
0076 }
0077 
0078 QTEST_MAIN(DatabaseBenchmark)
0079 
0080 #include "databasebenchmark.moc"