commit 59cbaf1b90f4dfde5db35d4c9d474497f9d72e11
parent e357bcbbb0cc23129c1719ae38819fb4a46c0c1e
Author: Andrew Laack <andrew@laack.co>
Date: Wed, 30 Sep 2026 13:48:14 -0500
Basic benchmark
Diffstat:
3 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
@@ -11,6 +11,7 @@ install: build
clean:
rm -rf test*.out foreseen.out
+ rm -rf bench*.out
rm -rf *.gcda *.gcno
rm -rf coverage.info
rm -rf coverage-html
@@ -46,6 +47,10 @@ crash-test:
./test5.out
rm test5.out
+benchmark:
+ ${BCOMMAND_P} benchmarking/render-bench.cpp ${BCOMMAND_S} -o bench1.out
+ ./bench1.out
+
test: pure-test browser-test fetch-test puppet-test
lcov --capture --directory . --output-file coverage.info \
--no-external \
diff --git a/benchmarking/render-bench.cpp b/benchmarking/render-bench.cpp
@@ -0,0 +1,38 @@
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/benchmark/catch_benchmark_all.hpp>
+#include <rapidcheck.h>
+#include "../include/render.hpp"
+#include <ncurses.h>
+#include <rapidcheck/Check.h>
+#include <rapidcheck/Log.h>
+#include <string>
+
+TEST_CASE("Benchmarking small file") {
+
+ setenv("EDITOR", "test" , 1);
+
+ for(int x = 8; x < 10; ++x) {
+ for(int y = 8; y < 10; ++y) {
+ BENCHMARK("All line types - X: " + std::to_string(x) + " Y: " + std::to_string(y)) {
+ Browser* bPtr = new Browser {};
+ Browser& b = *bPtr;
+ DrawState ds {};
+ ds.bPtr = bPtr;
+ std::string st = "file:///home/andrew/gitRepos/gemini-browser/tests/sites/all_line_types.gmi";
+
+
+ REQUIRE(mainLoop(ds, b, 'o',x,y));
+
+ for(auto& ch: st) {
+ REQUIRE(mainLoop(ds, b, ch,x,y));
+ }
+
+ REQUIRE(mainLoop(ds, b, '\n',x,y));
+
+ REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "file:///home/andrew/gitRepos/gemini-browser/tests/sites/all_line_types.gmi");
+ delete bPtr;
+ };
+ }
+ }
+}
+
diff --git a/config.mk b/config.mk
@@ -9,13 +9,17 @@ TLIBS = -lCatch2Main -lCatch2 -lrapidcheck ${LIBS}
CC = g++
IFLAGS = -Ofast -std=c++23
+BFLAGS = -O0 -std=c++23
DFLAGS = -O0 -fsanitize=address,undefined -g -std=c++23 -Wpedantic -Wall -Wextra -Wno-deprecated-declarations -D DEBUG_MODE
CTFLAGS = -O0 -fsanitize=undefined -g -std=c++23 -Wpedantic -Wall -Wextra -Wno-deprecated-declarations -fprofile-arcs -ftest-coverage -fPIC -D DEBUG_MODE
BASE_FILES = src/identity-manager.cpp src/quote.cpp src/list-item.cpp src/preformatted.cpp src/format-switch.cpp src/cache.cpp src/link.cpp src/plaintext.cpp src/site.cpp src/utils.cpp src/gemini-client.cpp src/browser.cpp src/heading.cpp src/render.cpp
-COMMAND_P = ${CC} ${CFLAGS} -D NDEBUG
+BCOMMAND_P = ${CC} ${BFLAGS} -D DEBUG_MODE
+BCOMMAND_S = ${BASE_FILES} ${TLIBS}
+
+COMMAND_P = ${CC} ${IFLAGS} -D NDEBUG
COMMAND_S = ${BASE_FILES} ${LIBS}
TCOMMAND_P = ${CC} ${CTFLAGS}