Lolly
1.4.27
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
.minEpochTime (std::chrono::milliseconds (20));
18
bench
.run (
"construct string"
, [&] {
19
string
(
"abc"
);
20
string
();
21
});
22
bench
.run (
"equality of string"
, [&] {
23
static
string
a (
"abc"
),
b
;
24
a ==
b
;
25
});
26
bench
.run (
"equality of larger string"
, [&] {
27
static
string
a (
"equality of larger string"
),
28
b
(
"equality of larger strinG"
);
29
a ==
b
;
30
});
31
bench
.run (
"compare string"
, [&] {
32
static
string
a (
"ab"
),
b
(
"b"
);
33
a <=
b
;
34
});
35
bench
.run (
"compare larger string"
, [&] {
36
static
string
a (
"compare larger string"
),
b
(
"compare LARGER string"
);
37
a <=
b
;
38
});
39
bench
.run (
"slice string"
, [&] {
40
static
string
a (
"abcdefgh"
);
41
a (2, 3);
42
});
43
bench
.run (
"slice string with larger range"
, [&] {
44
static
string
a (
"abcdefgh"
);
45
a (1, 6);
46
});
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:62
lolly::init_tbox
void init_tbox()
Definition
sys_utils.cpp:169
is_quoted
bool is_quoted(string s)
Definition
string.cpp:408
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