Lolly 1.4.28
Loading...
Searching...
No Matches
string_u16_bench.cpp
Go to the documentation of this file.
1/** \file lolly_string_bench.cpp
2 * \copyright GPLv3
3 * \details Benchmark for string
4 * \author jingkaimori
5 * \date 2024
6 */
7
9#include <nanobench.h>
10
12
13static ankerl::nanobench::Bench bench;
14
15namespace lolly {
16extern void init_tbox ();
17} // namespace lolly
18
19int
20main () {
22#ifdef OS_WASM
23 bench.minEpochIterations (2000);
24#else
25 bench.minEpochIterations (200000);
26#endif
27 bench.run ("construct string_u16", [&] { string_u16 (); });
28 bench.run ("equality of string", [&] {
29 static string_u16 a (u"abc"), b;
30 a == b;
31 });
32 bench.run ("equality of larger string", [&] {
33 static string_u16 a (u"equality of larger string"),
34 b (u"equality of larger string");
35 a == b;
36 });
37 bench.run ("compare string", [&] {
38 static string_u16 a (u"ab"), b (u"b");
39 a <= b;
40 });
41 bench.run ("compare larger string", [&] {
42 static string_u16 a (u"compare larger string"),
43 b (u"compare LARGEr string");
44 a <= b;
45 });
46 bench.run ("slice string", [&] {
47 static string_u16 a (u"abcdefgh");
48 a (2, 3);
49 });
50 bench.run ("slice string with larger range", [&] {
51 static string_u16 a (u"abcdefgh");
52 a (1, 6);
53 });
54 bench.run ("concat string", [&] {
55 static string_u16 a (u"abc"), b (u"de");
56 a* b;
57 });
58 bench.run ("append string", [&] {
59 static string_u16 a (u"abc"), b (u"de");
60 a << b;
61 });
62}
blackbox b[13]
The list class represents a linked list.
Definition list.hpp:48
void init_tbox()
static ankerl::nanobench::Bench bench
int main()