benchmarking prototype

This commit is contained in:
anon 2023-09-09 18:14:57 +02:00
parent 3803bbbd9d
commit fc7313c1a3
3 changed files with 40 additions and 31 deletions

View File

@ -1,20 +1,19 @@
DEBUG := 0
#CPPFLAGS := -DDEBUG
#CXXFLAGS := -O0 -ggdb
CXXFLAGS := -O2
BUILD.cpp := ${CXX} ${CXXFLAGS} ${CPPFLAGS}
.ONESHELL:
test: build
for $$i i *.out;
do time $$i
done
export LD_LIBRARY_PATH=$$(realpath .):$$LD_LIBRARY_PATH
perf stat -r 10000 ./gnu_racer.out
perf stat -r 10000 ./jeger_racer.out
build: jeger gnu
jeger: ../source/vector.c ../source/jeger.c jeger_racer.cpp
gcc -shared ../source/vector.c -o vector.so
gcc -shared ../source/jeger.c -o jeger.so
${BUILD.cpp} -I../source/ vector.so jeger.so jeger_racer.cpp -o jeger_racer.out
g++ -shared ../source/vector.c -o vector.so
g++ -shared ../source/jeger.c -o jeger.so
${BUILD.cpp} -I../source/ jeger_racer.cpp vector.so jeger.so -o jeger_racer.out
gnu: gnu_racer.cpp
${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>
static
@ -5,12 +10,13 @@ void TEST(const char * const what,
const char * const on,
const bool expect){
regex_t * r = regcomp(&r, pattern, REG_EXTENDED | REG_NOSUB);
int result = regexec(regex, input, 0, NULL, 0);
regfree(r);
regex_t r;
regcomp(&r, what, REG_EXTENDED | REG_NOSUB);
int result = regexec(&r, on, 0, NULL, 0);
regfree(&r);
#if DEBUG
assert((result != -1) && (expect == (bool)result));
assert((result != -1) && (expect == !((bool)result)));
#endif
}
@ -21,17 +27,17 @@ signed main(){
TEST( R"del(ss)del", "sss", true);
TEST( R"del(sss)del", "ss", false);
TEST( R"del(ab\+c)del", "abc", true);
TEST(R"del(ef\+g1)del", "effffg1", true);
TEST(R"del(efg1\+)del", "efg", false);
TEST(R"del(efg1\+)del", "efg1", true);
TEST(R"del(efg1\+)del", "efg11", true);
TEST( R"del(ab+c)del", "abc", true);
TEST(R"del(ef+g1)del", "effffg1", true);
TEST(R"del(efg1+)del", "efg", false);
TEST(R"del(efg1+)del", "efg1", true);
TEST(R"del(efg1+)del", "efg11", true);
TEST( R"del(a\+a)del", "aaa", true);
TEST( R"del(a\+a)del", "aa", true);
TEST( R"del(a\+a)del", "a", false);
TEST( R"del(a\+a)del", "aaa", true);
TEST(R"del(a\++)del", "aaa", false);
TEST( R"del(a+a)del", "aaa", true);
TEST( R"del(a+a)del", "aa", true);
TEST( R"del(a+a)del", "a", false);
TEST( R"del(a+a)del", "aaa", true);
TEST(R"del(a+\+)del", "aaa", false);
TEST( R"del(ab*c)del", "abc", 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", "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", "ne", true);
TEST( R"del(ne.o)del", "neto", true);
TEST(R"del(ne.\+o)del", "nettto", true);
TEST(R"del(ne.\+o)del", "neo", false);
TEST(R"del(ne.\+o)del", "neoo", true);
TEST(R"del(ne.+o)del", "nettto", true);
TEST(R"del(ne.+o)del", "neo", false);
TEST(R"del(ne.+o)del", "neoo", true);
TEST(R"del(ne.*o)del", "neo", true);
TEST(R"del(ne.)del", "ne\t", true);
TEST(R"del(ne\t)del", "ne", false);
TEST(R"del(ne\t)del", "ne\t", true);
TEST(R"del(ne\t)del", "net", false);
TEST( "ne\t", "ne\t", true); //XXX
TEST(R"del(ne )del", "net", false);
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(\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([A-Za-z]+)del", "HelloWorld", true);

View File

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