Lolly 1.4.27
Loading...
Searching...
No Matches
list_bench.cpp
Go to the documentation of this file.
1/** \file list_bench.cpp
2 * \copyright GPLv3
3 * \details Benchmark for list
4 * \author Darcy Shen
5 * \date 2024
6 */
7
8#include "list.hpp"
9#include <nanobench.h>
10
11static ankerl::nanobench::Bench bench;
12
13static list<long>
14gen (int64_t n) {
15 auto normal= list<long> ();
16 for (long i= 0; i < n; i++)
17 normal << i;
18 return normal;
19}
20
21int
22main () {
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.
The list class represents a linked list.
Definition list.hpp:48
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
int main()
auto normal
Definition list_test.cpp:26