1
0
mirror of https://github.com/chylex/Nextcloud-Desktop.git synced 2024-10-22 22:42:44 +02:00
Nextcloud-Desktop/test/benchmarks/benchlargesync.cpp
Jocelyn Turcotte 605a18ff73 Tests: Add a large sync benchmark
This simulates a ~50k files sync that can be used to measure memory
usage without having to wait for a server.
2017-01-25 23:26:23 +01:00

44 lines
1.3 KiB
C++

/*
* This software is in the public domain, furnished "as is", without technical
* support, and with no warranty, express or implied, as to its usefulness for
* any purpose.
*
*/
#include "syncenginetestutils.h"
#include <syncengine.h>
using namespace OCC;
int numDirs = 0;
int numFiles = 0;
template<int filesPerDir, int dirPerDir, int maxDepth>
void addBunchOfFiles(int depth, const QString &path, FileModifier &fi) {
for (int fileNum = 1; fileNum <= filesPerDir; ++fileNum) {
QString name = QStringLiteral("file") + QString::number(fileNum);
fi.insert(path.isEmpty() ? name : path + "/" + name);
numFiles++;
}
if (depth >= maxDepth)
return;
for (char dirNum = 1; dirNum <= dirPerDir; ++dirNum) {
QString name = QStringLiteral("dir") + QString::number(dirNum);
QString subPath = path.isEmpty() ? name : path + "/" + name;
fi.mkdir(subPath);
numDirs++;
addBunchOfFiles<filesPerDir, dirPerDir, maxDepth>(depth + 1, subPath, fi);
}
}
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
FakeFolder fakeFolder{FileInfo{}};
addBunchOfFiles<10, 8, 4>(0, "", fakeFolder.localModifier());
qDebug() << "NUMFILES" << numFiles;
qDebug() << "NUMDIRS" << numDirs;
return fakeFolder.syncOnce() ? 0 : -1;
}