Compare commits

...

2 Commits

Author SHA1 Message Date
0456f8595b conditional silence error 2023-09-09 18:15:14 +02:00
fc7313c1a3 benchmarking prototype 2023-09-09 18:14:57 +02:00
4 changed files with 43 additions and 32 deletions

View File

@ -1,20 +1,19 @@
DEBUG := 0 #CPPFLAGS := -DDEBUG
#CXXFLAGS := -O0 -ggdb
CXXFLAGS := -O2
BUILD.cpp := ${CXX} ${CXXFLAGS} ${CPPFLAGS} BUILD.cpp := ${CXX} ${CXXFLAGS} ${CPPFLAGS}
.ONESHELL:
test: build test: build
for $$i i *.out; export LD_LIBRARY_PATH=$$(realpath .):$$LD_LIBRARY_PATH
do time $$i perf stat -r 10000 ./gnu_racer.out
done perf stat -r 10000 ./jeger_racer.out
build: jeger gnu build: jeger gnu
jeger: ../source/vector.c ../source/jeger.c jeger_racer.cpp jeger: ../source/vector.c ../source/jeger.c jeger_racer.cpp
gcc -shared ../source/vector.c -o vector.so g++ -shared ../source/vector.c -o vector.so
gcc -shared ../source/jeger.c -o jeger.so g++ -shared ../source/jeger.c -o jeger.so
${BUILD.cpp} -I../source/ vector.so jeger.so jeger_racer.cpp -o jeger_racer.out ${BUILD.cpp} -I../source/ jeger_racer.cpp vector.so jeger.so -o jeger_racer.out
gnu: gnu_racer.cpp gnu: gnu_racer.cpp
${BUILD.cpp} gnu_racer.cpp -o gnu_racer.out ${BUILD.cpp} gnu_racer.cpp -o gnu_racer.out

View File

@ -1,3 +1,8 @@
#if DEBUG
# include <assert.h>
#endif
#include <stddef.h>
#include <regex.h> #include <regex.h>
static static
@ -5,12 +10,13 @@ void TEST(const char * const what,
const char * const on, const char * const on,
const bool expect){ const bool expect){
regex_t * r = regcomp(&r, pattern, REG_EXTENDED | REG_NOSUB); regex_t r;
int result = regexec(regex, input, 0, NULL, 0); regcomp(&r, what, REG_EXTENDED | REG_NOSUB);
regfree(r); int result = regexec(&r, on, 0, NULL, 0);
regfree(&r);
#if DEBUG #if DEBUG
assert((result != -1) && (expect == (bool)result)); assert((result != -1) && (expect == !((bool)result)));
#endif #endif
} }
@ -21,17 +27,17 @@ signed main(){
TEST( R"del(ss)del", "sss", true); TEST( R"del(ss)del", "sss", true);
TEST( R"del(sss)del", "ss", false); TEST( R"del(sss)del", "ss", false);
TEST( R"del(ab\+c)del", "abc", true); TEST( R"del(ab+c)del", "abc", true);
TEST(R"del(ef\+g1)del", "effffg1", true); TEST(R"del(ef+g1)del", "effffg1", true);
TEST(R"del(efg1\+)del", "efg", false); TEST(R"del(efg1+)del", "efg", false);
TEST(R"del(efg1\+)del", "efg1", true); TEST(R"del(efg1+)del", "efg1", true);
TEST(R"del(efg1\+)del", "efg11", true); TEST(R"del(efg1+)del", "efg11", true);
TEST( R"del(a\+a)del", "aaa", true); TEST( R"del(a+a)del", "aaa", true);
TEST( R"del(a\+a)del", "aa", true); TEST( R"del(a+a)del", "aa", true);
TEST( R"del(a\+a)del", "a", false); TEST( R"del(a+a)del", "a", false);
TEST( R"del(a\+a)del", "aaa", true); TEST( R"del(a+a)del", "aaa", true);
TEST(R"del(a\++)del", "aaa", false); TEST(R"del(a+\+)del", "aaa", false);
TEST( R"del(ab*c)del", "abc", true); TEST( R"del(ab*c)del", "abc", true);
TEST(R"del(ef*g1)del", "effffg1", true); TEST(R"del(ef*g1)del", "effffg1", true);
@ -41,26 +47,26 @@ signed main(){
TEST( R"del(ne.)del", "net", true); TEST( R"del(ne.)del", "net", true);
TEST( R"del(ne.)del", "ne", false); TEST( R"del(ne.)del", "ne", false);
TEST(R"del(ne.\+)del", "neoo", true); TEST(R"del(ne.+)del", "neoo", true);
TEST(R"del(ne.*)del", "neoo", true); TEST(R"del(ne.*)del", "neoo", true);
TEST(R"del(ne.*)del", "ne", true); TEST(R"del(ne.*)del", "ne", true);
TEST( R"del(ne.o)del", "neto", true); TEST( R"del(ne.o)del", "neto", true);
TEST(R"del(ne.\+o)del", "nettto", true); TEST(R"del(ne.+o)del", "nettto", true);
TEST(R"del(ne.\+o)del", "neo", false); TEST(R"del(ne.+o)del", "neo", false);
TEST(R"del(ne.\+o)del", "neoo", true); TEST(R"del(ne.+o)del", "neoo", true);
TEST(R"del(ne.*o)del", "neo", true); TEST(R"del(ne.*o)del", "neo", true);
TEST(R"del(ne.)del", "ne\t", true); TEST(R"del(ne.)del", "ne\t", true);
TEST(R"del(ne\t)del", "ne", false); TEST(R"del(ne\t)del", "ne", false);
TEST(R"del(ne\t)del", "ne\t", true); TEST( "ne\t", "ne\t", true); //XXX
TEST(R"del(ne\t)del", "net", false); TEST(R"del(ne )del", "net", false);
TEST(R"del(ne)del", "ne\t", true); TEST(R"del(ne)del", "ne\t", true);
TEST(R"del(\sa)del", " a", true); TEST(R"del(\sa)del", " a", true);
TEST(R"del(\sa)del", " a ", true); TEST(R"del(\sa)del", " a ", true);
TEST(R"del(\wi)del", "hi", true); TEST(R"del(\wi)del", "hi", true);
TEST(R"del(\w\+)del", "asd", true); TEST(R"del(\w+)del", "asd", true);
TEST(R"del(\w*)del", "", true); TEST(R"del(\w*)del", "", true);
TEST( R"del([A-Za-z]+)del", "HelloWorld", true); TEST( R"del([A-Za-z]+)del", "HelloWorld", true);

View File

@ -1,3 +1,7 @@
#if DEBUG
# include <assert.h>
#endif
#include <jeger.h> #include <jeger.h>
static static

View File

@ -1,4 +1,6 @@
#pragma GCC diagnostic ignored "-Wc++20-extensions" #if __cplusplus
# pragma GCC diagnostic ignored "-Wc++20-extensions"
#endif
#include "jeger.h" #include "jeger.h"