Add BSTRLIB for MASTER STRING BENCHMARK
This commit is contained in:
1 parent
edb4ccf63e
commit
b2875f6ba0
3 files changed
+54
-3
No files matched your search
@@ -332,6 +332,7 @@ bench-string-step5:
|
|||||||
@./bench-string-2.exe 2000000 1
|
@./bench-string-2.exe 2000000 1
|
||||||
@./bench-string-2.exe 2000000 2
|
@./bench-string-2.exe 2000000 2
|
||||||
@./bench-string-2.exe 2000000 3
|
@./bench-string-2.exe 2000000 3
|
||||||
|
@./bench-string-2.exe 2000000 4
|
||||||
|
|
||||||
bench-string-pgo:
|
bench-string-pgo:
|
||||||
$(MAKE) bench-string XCFLAGS="-fprofile-generate=pgo"
|
$(MAKE) bench-string XCFLAGS="-fprofile-generate=pgo"
|
||||||
|
|||||||
@@ -27,9 +27,10 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "m-string.h"
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#include "m-string.h"
|
||||||
|
|
||||||
#ifdef BENCH_CAN_USE_SDS
|
#ifdef BENCH_CAN_USE_SDS
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "sds.h"
|
#include "sds.h"
|
||||||
@@ -40,6 +41,12 @@ extern "C" {
|
|||||||
#include "rapidstring.h"
|
#include "rapidstring.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BENCH_CAN_USE_BSTRLIB
|
||||||
|
#include "bstrlib.h"
|
||||||
|
#include "bstrwrap.h"
|
||||||
|
#include "bstraux.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BENCH
|
* BENCH
|
||||||
* 2000000
|
* 2000000
|
||||||
@@ -100,7 +107,7 @@ size_t bench_stl(unsigned n)
|
|||||||
|
|
||||||
return str.length();
|
return str.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t bench_mlib(unsigned n)
|
size_t bench_mlib(unsigned n)
|
||||||
{
|
{
|
||||||
string_t *tab = (string_t*) malloc (n * sizeof (string_t));
|
string_t *tab = (string_t*) malloc (n * sizeof (string_t));
|
||||||
@@ -136,6 +143,43 @@ size_t bench_mlib(unsigned n)
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef BENCH_CAN_USE_BSTRLIB
|
||||||
|
size_t bench_bstrlib(unsigned n)
|
||||||
|
{
|
||||||
|
vector<CBString> tab;
|
||||||
|
tab.resize(n);
|
||||||
|
for(unsigned i = 0; i < n; i++) {
|
||||||
|
char tmp[10];
|
||||||
|
sprintf(tmp, "%u", rand_get());
|
||||||
|
tab[i] = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
CBString str;
|
||||||
|
for(unsigned i = 0; i < n; i++) {
|
||||||
|
str += tab[permutation_tab[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t pos = 0;
|
||||||
|
do {
|
||||||
|
pos = str.find("1234", pos);
|
||||||
|
if (pos != string::npos) {
|
||||||
|
str.replace (pos, 4, "WELL");
|
||||||
|
}
|
||||||
|
} while (pos != string::npos);
|
||||||
|
|
||||||
|
pos = 0;
|
||||||
|
do {
|
||||||
|
pos = str.find("56789", pos);
|
||||||
|
if (pos != string::npos) {
|
||||||
|
str.replace (pos, 5, "DONE");
|
||||||
|
}
|
||||||
|
} while (pos != string::npos);
|
||||||
|
|
||||||
|
return str.length();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef BENCH_CAN_USE_SDS
|
#ifdef BENCH_CAN_USE_SDS
|
||||||
sds SDS_replace_at(sds str, size_t pos, size_t len, const char str2[])
|
sds SDS_replace_at(sds str, size_t pos, size_t len, const char str2[])
|
||||||
{
|
{
|
||||||
@@ -276,6 +320,12 @@ int main(int argc, const char *argv[])
|
|||||||
length = bench_rapidstring(n);
|
length = bench_rapidstring(n);
|
||||||
name = "RAPID";
|
name = "RAPID";
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef BENCH_CAN_USE_BSTRLIB
|
||||||
|
case 4:
|
||||||
|
length = bench_bstrlib(n);
|
||||||
|
name = "BSTRLIB";
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Update of integrating M*LIB, LIBSRT, SDS, RAPIDSTRING & GLIB
|
/* Update of integrating M*LIB, LIBSRT, SDS, RAPIDSTRING & GLIB
|
||||||
done by Patrick Pelissier
|
Copyright (c) 2018-2019 Patrick Pelissier
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in new issue
Block a user