Lolly
1.4.28
Loading...
Searching...
No Matches
bench
Kernel
Types
string_bench.cpp
Go to the documentation of this file.
1
/** \file string_bench.cpp
2
* \copyright GPLv3
3
* \details Benchmark for string
4
* \author jingkaimori
5
* \date 2024
6
*/
7
8
#include "
string.hpp
"
9
#include "
sys_utils.hpp
"
10
#include <nanobench.h>
11
12
static
ankerl::nanobench::Bench
bench
;
13
14
int
15
main
() {
16
lolly::init_tbox
();
17
bench
.run (
"construct string"
, [&] {
18
string
(
"abc"
);
19
string
();
20
});
21
bench
.run (
"equality of string"
, [&] {
22
static
string
a (
"abc"
),
b
;
23
a ==
b
;
24
});
25
bench
.run (
"equality of larger string"
, [&] {
26
static
string
a (
"equality of larger string"
),
27
b
(
"equality of larger strinG"
);
28
a ==
b
;
29
});
30
bench
.run (
"compare string"
, [&] {
31
static
string
a (
"ab"
),
b
(
"b"
);
32
a <=
b
;
33
});
34
bench
.run (
"compare larger string"
, [&] {
35
static
string
a (
"compare larger string"
),
b
(
"compare LARGER string"
);
36
a <=
b
;
37
});
38
bench
.run (
"slice string"
, [&] {
39
static
string
a (
"abcdefgh"
);
40
a (2, 3);
41
});
42
bench
.run (
"slice string with larger range"
, [&] {
43
static
string
a (
"abcdefgh"
);
44
a (1, 6);
45
});
46
bench
.minEpochIterations (40000);
47
bench
.run (
"concat string"
, [&] {
48
static
string
a (
"abc"
),
b
(
"de"
);
49
a*
b
;
50
});
51
bench
.run (
"append string"
, [&] {
52
static
string
a (
"abc"
),
b
(
"de"
);
53
a <<
b
;
54
});
55
bench
.run (
"hash of string"
, [&] {
56
static
string
a (
"accde"
);
57
hash
(a);
58
});
59
bench
.run (
"hash of larger string"
, [&] {
60
static
string
a (
"compare larger string ,compute hash of LARGER string"
);
61
hash
(a);
62
});
63
bench
.run (
"is quoted"
, [&] {
64
static
string
a (
"H\"ello TeXmacs\""
);
65
is_quoted
(a);
66
});
67
}
hash
int hash(pointer ptr)
Computes a hash value for a pointer.
Definition
basic.cpp:17
b
blackbox b[13]
Definition
blackbox_test.cpp:41
string
Definition
string.hpp:40
lolly::init_tbox
void init_tbox()
Definition
sys_utils.cpp:169
is_quoted
bool is_quoted(string s)
Definition
string.cpp:370
string.hpp
bench
static ankerl::nanobench::Bench bench
Definition
string_bench.cpp:12
main
int main()
Definition
string_bench.cpp:15
sys_utils.hpp
Generated by
1.10.0