2018-08-30 21:01:03 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include "testparseperformance.h"
|
2020-10-17 10:32:22 +00:00
|
|
|
#include "core/device.h"
|
core: introduce divelog structure
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.
Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).
The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.
To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.
The whole commit is large, but was mostly an automatic
conversion.
One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-08 20:31:08 +00:00
|
|
|
#include "core/divelog.h"
|
2019-03-04 22:20:29 +00:00
|
|
|
#include "core/divesite.h"
|
2019-05-31 14:09:14 +00:00
|
|
|
#include "core/trip.h"
|
2019-03-03 21:29:40 +00:00
|
|
|
#include "core/file.h"
|
2018-08-30 21:01:03 +00:00
|
|
|
#include "core/git-access.h"
|
2018-09-08 17:46:11 +00:00
|
|
|
#include "core/settings/qPrefProxy.h"
|
|
|
|
#include "core/settings/qPrefCloudStorage.h"
|
2018-08-30 21:01:03 +00:00
|
|
|
#include <QFile>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QNetworkProxy>
|
2022-02-10 01:14:22 +00:00
|
|
|
#include "QTextCodec"
|
2018-08-30 21:01:03 +00:00
|
|
|
|
2020-04-26 23:36:27 +00:00
|
|
|
#define LARGE_TEST_REPO "https://github.com/Subsurface/large-anonymous-sample-data"
|
2018-08-30 21:01:03 +00:00
|
|
|
|
|
|
|
void TestParsePerformance::initTestCase()
|
|
|
|
{
|
|
|
|
/* we need to manually tell that the resource exists, because we are using it as library. */
|
|
|
|
Q_INIT_RESOURCE(subsurface);
|
|
|
|
|
|
|
|
// Set UTF8 text codec as in real applications
|
|
|
|
QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106));
|
|
|
|
|
|
|
|
// first, setup the preferences an proxy information
|
|
|
|
copy_prefs(&default_prefs, &prefs);
|
|
|
|
QCoreApplication::setOrganizationName("Subsurface");
|
|
|
|
QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
|
|
|
|
QCoreApplication::setApplicationName("Subsurface");
|
|
|
|
qPrefProxy::load();
|
|
|
|
qPrefCloudStorage::load();
|
|
|
|
|
|
|
|
QNetworkProxy proxy;
|
|
|
|
proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type));
|
|
|
|
proxy.setHostName(prefs.proxy_host);
|
|
|
|
proxy.setPort(prefs.proxy_port);
|
|
|
|
if (prefs.proxy_auth) {
|
|
|
|
proxy.setUser(prefs.proxy_user);
|
|
|
|
proxy.setPassword(prefs.proxy_pass);
|
|
|
|
}
|
|
|
|
QNetworkProxy::setApplicationProxy(proxy);
|
|
|
|
|
|
|
|
// now cleanup the cache dir in case there's something weird from previous runs
|
|
|
|
QString localCacheDir(get_local_dir(LARGE_TEST_REPO, "git"));
|
|
|
|
QDir localCacheDirectory(localCacheDir);
|
|
|
|
QCOMPARE(localCacheDirectory.removeRecursively(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestParsePerformance::init()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestParsePerformance::cleanup()
|
|
|
|
{
|
|
|
|
clear_dive_file_data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestParsePerformance::parseSsrf()
|
|
|
|
{
|
|
|
|
// parsing of a V2 file should work
|
|
|
|
QFile largeSsrfFile(SUBSURFACE_TEST_DATA "/dives/large-anon.ssrf");
|
|
|
|
if (!largeSsrfFile.exists()) {
|
|
|
|
qDebug() << "missing large sample data file - available at " LARGE_TEST_REPO;
|
|
|
|
qDebug() << "clone the repo, uncompress the file and copy it to " SUBSURFACE_TEST_DATA "/dives/large-anon.ssrf";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QBENCHMARK {
|
core: introduce divelog structure
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.
Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).
The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.
To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.
The whole commit is large, but was mostly an automatic
conversion.
One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-08 20:31:08 +00:00
|
|
|
parse_file(SUBSURFACE_TEST_DATA "/dives/large-anon.ssrf", &divelog);
|
2018-08-30 21:01:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestParsePerformance::parseGit()
|
|
|
|
{
|
|
|
|
// some more necessary setup
|
|
|
|
git_libgit2_init();
|
|
|
|
|
|
|
|
// first parse this once to populate the local cache - this way network
|
|
|
|
// effects don't dominate the parse time
|
core: introduce divelog structure
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.
Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).
The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.
To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.
The whole commit is large, but was mostly an automatic
conversion.
One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-08 20:31:08 +00:00
|
|
|
parse_file(LARGE_TEST_REPO "[git]", &divelog);
|
2018-08-30 21:01:03 +00:00
|
|
|
|
|
|
|
cleanup();
|
|
|
|
|
|
|
|
QBENCHMARK {
|
core: introduce divelog structure
The parser API was very annoying, as a number of tables
to-be-filled were passed in as pointers. The goal of this
commit is to collect all these tables in a single struct.
This should make it (more or less) clear what is actually
written into the divelog files.
Moreover, it should now be rather easy to search for
instances, where the global logfile is accessed (and it
turns out that there are many!).
The divelog struct does not contain the tables as substructs,
but only collects pointers. The idea is that the "divelog.h"
file can be included without all the other files describing
the numerous tables.
To make it easier to use from C++ parts of the code, the
struct implements a constructor and a destructor. Sadly,
we can't use smart pointers, since the pointers are accessed
from C code. Therfore the constructor and destructor are
quite complex.
The whole commit is large, but was mostly an automatic
conversion.
One oddity of note: the divelog structure also contains
the "autogroup" flag, since that is saved in the divelog.
This actually fixes a bug: Before, when importing dives
from a different log, the autogroup flag was overwritten.
This was probably not intended and does not happen anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-11-08 20:31:08 +00:00
|
|
|
parse_file(LARGE_TEST_REPO "[git]", &divelog);
|
2018-08-30 21:01:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN(TestParsePerformance)
|