Benchmark and Test LinkParser (#4436)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -7,6 +7,7 @@ set(benchmark_SOURCES
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/FormatTime.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/Helpers.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/LimitedQueue.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/LinkParser.cpp
|
||||
# Add your new file above this line!
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Application.hpp"
|
||||
#include "BaseSettings.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "common/Channel.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "controllers/highlights/HighlightController.hpp"
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
Emotes *getEmotes() override
|
||||
IEmotes *getEmotes() override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
@@ -100,6 +100,10 @@ public:
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
IUserDataController *getUserData() override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AccountController accounts;
|
||||
HighlightController highlights;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "common/LinkParser.hpp"
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <optional>
|
||||
|
||||
using namespace chatterino;
|
||||
|
||||
const QString INPUT = QStringLiteral(
|
||||
"If your Chatterino isn't loading FFZ emotes, update to the latest nightly "
|
||||
"(or 2.4.2 if its out) "
|
||||
"https://github.com/Chatterino/chatterino2/releases/tag/nightly-build "
|
||||
"AlienPls https://www.youtube.com/watch?v=ELBBiBDcWc0 "
|
||||
"127.0.3 aaaa xd 256.256.256.256 AsdQwe xd 127.0.0.1 https://. https://.be "
|
||||
"https://a http://a.b https://a.be ftp://xdd.com "
|
||||
"this is a text lol . ://foo.com //aa.de :/foo.de xd.XDDDDDD ");
|
||||
|
||||
static void BM_LinkParsing(benchmark::State &state)
|
||||
{
|
||||
QStringList words = INPUT.split(' ');
|
||||
|
||||
// Make sure the TLDs are loaded
|
||||
{
|
||||
benchmark::DoNotOptimize(LinkParser("xd.com").getCaptured());
|
||||
}
|
||||
|
||||
for (auto _ : state)
|
||||
{
|
||||
for (auto word : words)
|
||||
{
|
||||
LinkParser parser(word);
|
||||
if (parser.hasMatch())
|
||||
{
|
||||
benchmark::DoNotOptimize(parser.getCaptured());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(BM_LinkParsing);
|
||||
Reference in New Issue
Block a user