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

Go to the source code of this file.

Functions

static list< longgen (int64_t n)
 
int main ()
 

Variables

static ankerl::nanobench::Bench bench
 

Detailed Description

Benchmark for list

Author
Darcy Shen
Date
2024

Definition in file list_bench.cpp.

Function Documentation

◆ gen()

static list< long > gen ( int64_t n)
static

Definition at line 14 of file list_bench.cpp.

14 {
15 auto normal= list<long> ();
16 for (long i= 0; i < n; i++)
17 normal << i;
18 return normal;
19}
The list class represents a linked list.
Definition list.hpp:48
auto normal
Definition list_test.cpp:26

◆ main()

int main ( )

Definition at line 22 of file list_bench.cpp.

22 {
23 list<long> l1 = gen (1);
24 list<long> l4 = gen (4);
25 list<long> l16 = gen (16);
26 list<long> l32 = gen (32);
27 list<long> l32_2= gen (32);
28 list<long> l64 = gen (64);
29
30 bench.run ("last_item 1", [&] { last_item (l1); });
31 bench.run ("last_item 4", [&] { last_item (l4); });
32 bench.run ("last_item 16", [&] { last_item (l16); });
33
34 bench.run ("N 32", [&] { N (l32); });
35
36 bench.minEpochIterations (100000);
37 bench.run ("contains 1", [&] { contains (l32, 1L); });
38 bench.run ("contains 16", [&] { contains (l32, 16L); });
39 bench.run ("contains 32", [&] { contains (l32, 32L); });
40 bench.run ("contains 64", [&] { contains (l32, 64L); });
41
42 bench.minEpochIterations (40000);
43 bench.run ("l1 == l2 32", [&] { l32 == l32_2; });
44}
int N(array< T > a)
Get the length of the array.
Definition array.hpp:170
bool contains(T a, array< T > b)
Check if an array contains a specified element.
T last_item(list< T > l)
Return the last item of the list. The input list must not be an empty list.
Definition list.ipp:79
static list< long > gen(int64_t n)
static ankerl::nanobench::Bench bench

Variable Documentation

◆ bench

Definition at line 11 of file list_bench.cpp.