Lolly 1.4.27
Loading...
Searching...
No Matches
Functions | Variables
string_bench.cpp File Reference
#include "string.hpp"
#include "sys_utils.hpp"
#include <nanobench.h>
Include dependency graph for string_bench.cpp:

Go to the source code of this file.

Functions

int main ()
 

Variables

static ankerl::nanobench::Bench bench
 

Detailed Description

Benchmark for string

Author
jingkaimori
Date
2024

Definition in file string_bench.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 15 of file string_bench.cpp.

15 {
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}
int hash(pointer ptr)
Computes a hash value for a pointer.
Definition basic.cpp:17
blackbox b[13]
void init_tbox()
bool is_quoted(string s)
Definition string.cpp:408
static ankerl::nanobench::Bench bench

Variable Documentation

◆ bench

Definition at line 12 of file string_bench.cpp.