jaulib v1.3.6
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
test_cow_darray_perf01.cpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2020 Gothel Software e.K.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24#include <cassert>
25#include <cstring>
26#include <vector>
27
28#include <jau/test/catch2_ext.hpp>
29
30#include "test_datatype01.hpp"
31
32#include <jau/basic_types.hpp>
33#include <jau/basic_algos.hpp>
34#include <jau/darray.hpp>
35#include <jau/cow_darray.hpp>
36#include <jau/cow_vector.hpp>
38#include <jau/callocator.hpp>
40
41/**
42 * Performance test of jau::darray, jau::cow_darray and jau::cow_vector.
43 */
44using namespace jau;
45
46#define RUN_RESERVE_BENCHMARK 0
47#define RUN_INDEXED_BENCHMARK 0
48
49/****************************************************************************************
50 ****************************************************************************************/
51
52template< class Cont >
53static void print_container_info(const std::string& type_id, const Cont &c,
54 std::enable_if_t< jau::is_darray_type<Cont>::value, bool> = true )
55{
56 printf("\nContainer Type %s (a darray, a cow %d):\n - Uses memmove %d (trivially_copyable %d); realloc %d; base_of jau::callocator %d; secmem %d; size %d bytes\n",
57 type_id.c_str(), jau::is_cow_type<Cont>::value,
58 Cont::uses_memmove,
59 std::is_trivially_copyable_v<typename Cont::value_type>,
60 Cont::uses_realloc,
61 std::is_base_of_v<jau::callocator<typename Cont::value_type>, typename Cont::allocator_type>,
62 Cont::uses_secmem,
63 (int)sizeof(c));
64}
65
66template<class Cont>
67static void print_container_info(const std::string& type_id, const Cont &c,
68 std::enable_if_t< !jau::is_darray_type<Cont>::value, bool> = true )
69{
70 printf("\nContainer Type %s (!darray, a cow %d); size %d bytes\n",
71 type_id.c_str(), jau::is_cow_type<Cont>::value, (int)sizeof(c));
72}
73
74/****************************************************************************************
75 ****************************************************************************************/
76
77static uint8_t start_addr_b[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
79
80/****************************************************************************************
81 ****************************************************************************************/
82
83template<class T, typename Size_type>
84const DataType01 * findDataSet01_idx(T& data, DataType01 const & elem) noexcept {
85 const Size_type size = data.size();
86 for (Size_type i = 0; i < size; ++i) {
87 DataType01 & e = data[i];
88 if ( elem == e ) {
89 return &e;
90 }
91 }
92 return nullptr;
93}
94
95template<class T, typename Size_type>
96static int test_00_list_idx(T& data) {
97 int some_number = 0; // add some validated work, avoiding any 'optimization away'
98 const Size_type size = data.size();
99 for (Size_type i = 0; i < size; ++i) {
100 const DataType01 & e = data[i];
101 some_number += e.nop();
102 }
103 REQUIRE(some_number > 0);
104 return some_number;
105}
106
107template<class T, typename Size_type>
108const DataType01 * findDataSet01_itr(T& data, DataType01 const & elem,
109 std::enable_if_t< is_cow_type<T>::value, bool> = true) noexcept
110{
111 typename T::const_iterator first = data.cbegin();
112 for (; !first.is_end(); ++first) {
113 if (*first == elem) {
114 return &(*first);
115 }
116 }
117 return nullptr;
118}
119template<class T, typename Size_type>
120const DataType01 * findDataSet01_itr(T& data, DataType01 const & elem,
121 std::enable_if_t< !is_cow_type<T>::value, bool> = true) noexcept
122{
123 typename T::const_iterator first = data.cbegin();
124 typename T::const_iterator last = data.cend();
125 for (; first != last; ++first) {
126 if (*first == elem) {
127 return &(*first);
128 }
129 }
130 return nullptr;
131}
132
133template<class T>
134static int test_00_list_itr(T& data,
135 std::enable_if_t< is_cow_type<T>::value, bool> = true )
136{
137 int some_number = 0; // add some validated work, avoiding any 'optimization away'
138 typename T::const_iterator first = data.cbegin();
139 for (; !first.is_end(); ++first) {
140 some_number += (*first).nop();
141 }
142 REQUIRE(some_number > 0);
143 return some_number;
144}
145
146template<class T>
147static int test_00_list_itr(T& data,
148 std::enable_if_t< !is_cow_type<T>::value, bool> = true )
149{
150 int some_number = 0; // add some validated work, avoiding any 'optimization away'
151 typename T::const_iterator first = data.cbegin();
152 typename T::const_iterator last = data.cend();
153 for (; first != last; ++first) {
154 some_number += (*first).nop();
155 }
156 REQUIRE(some_number > 0);
157 return some_number;
158}
159
160
161template<class T, typename Size_type>
162static void test_00_seq_find_idx(T& data) {
164 const Size_type size = data.size();
165 Size_type fi = 0, i=0;
166
167 for(; i<size && a0.next(); ++i) {
168 DataType01 elem(a0, static_cast<uint8_t>(1));
169 const DataType01 *found = findDataSet01_idx<T, Size_type>(data, elem);
170 if( nullptr != found ) {
171 ++fi;
172 found->nop();
173 }
174 }
175 REQUIRE(fi == i);
176}
177
178template<class T, typename Size_type>
179static void test_00_seq_find_itr(T& data) {
181 const Size_type size = data.size();
182 Size_type fi = 0, i=0;
183
184 for(; i<size && a0.next(); ++i) {
185 DataType01 elem(a0, static_cast<uint8_t>(1));
186 const DataType01 *found = findDataSet01_itr<T, Size_type>(data, elem);
187 if( nullptr != found ) {
188 ++fi;
189 found->nop();
190 }
191 }
192 REQUIRE(fi == i);
193}
194
195template<class T, typename Size_type>
196static void test_00_seq_fill(T& data, const Size_type size) {
198 Size_type i=0;
199
200 for(; i<size && a0.next(); ++i) {
201 data.emplace_back( a0, static_cast<uint8_t>(1) );
202 }
203 REQUIRE(i == data.size());
204}
205
206template<class T, typename Size_type>
207static void test_00_seq_fill_unique_idx(T& data, const Size_type size) {
209 Size_type i=0, fi=0;
210
211 for(; i<size && a0.next(); ++i) {
212 DataType01 elem(a0, static_cast<uint8_t>(1));
213 const DataType01* exist = findDataSet01_idx<T, Size_type>(data, elem);
214 if( nullptr == exist ) {
215 data.push_back( std::move( elem ) );
216 ++fi;
217 }
218 }
219 REQUIRE(i == data.size());
220 REQUIRE(fi == size);
221}
222
223template<class value_type>
224static bool equal_comparator(const value_type& a, const value_type& b) noexcept {
225 return a == b;
226}
227
228template<class T, typename Size_type>
229static void test_00_seq_fill_unique_itr(T& data, const Size_type size,
230 std::enable_if_t< is_cow_type<T>::value, bool> = true)
231{
233 Size_type i=0, fi=0;
234
235#if 0
236 typename T::iterator first = data.begin();
237
238 for(; i<size && a0.next(); ++i, first.to_begin()) {
239 DataType01 elem(a0, static_cast<uint8_t>(1));
240 for (; !first.is_end(); ++first) {
241 if (*first == elem) {
242 break;
243 }
244 }
245 if( first.is_end() ) {
246 first.push_back( std::move( elem ) );
247 ++fi;
248 }
249 }
250 first.write_back();
251#else
252 for(; i<size && a0.next(); ++i) {
253 if( data.push_back_unique( DataType01(a0, static_cast<uint8_t>(1)),
255 ++fi;
256 }
257 }
258#endif
259 REQUIRE(i == data.size());
260 REQUIRE(fi == size);
261}
262
263template<class T, typename Size_type>
264static void test_00_seq_fill_unique_itr(T& data, const Size_type size,
265 std::enable_if_t< !is_cow_type<T>::value, bool> = true)
266{
268 Size_type i=0, fi=0;
269
270 for(; i<size && a0.next(); ++i) {
271 DataType01 elem(a0, static_cast<uint8_t>(1));
272 typename T::const_iterator first = data.cbegin();
273 typename T::const_iterator last = data.cend();
274 for (; first != last; ++first) {
275 if (*first == elem) {
276 break;
277 }
278 }
279 if( first == last ) {
280 data.push_back( std::move( elem ) );
281 ++fi;
282 }
283 }
284 REQUIRE(i == data.size());
285 REQUIRE(fi == size);
286}
287
288template<class T>
289static void print_mem(const std::string& pre, const T& data) {
290 std::size_t bytes_element = sizeof(DataType01);
291 std::size_t elements = data.size();
292 std::size_t bytes_net = elements * bytes_element;
293 std::size_t bytes_total = data.get_allocator().memory_usage;
294 double overhead = 0 == bytes_total ? 0.0 : ( 0 == bytes_net ? 10.0 : (double)bytes_total / (double)bytes_net );
295 printf("Mem: %s: Elements %s x %zu bytes; %s, %lf ratio\n",
296 pre.c_str(), to_decstring(elements, ',', 5).c_str(),
297 bytes_element, data.get_allocator().toString(10, 5).c_str(), overhead);
298 // 5: 1,000
299 // 7: 100,000
300 // 9: 1,000,000
301}
302
303/****************************************************************************************
304 ****************************************************************************************/
305
306template<class T, typename Size_type>
307static bool test_01_seq_fill_list_idx(const std::string& type_id, const Size_type size0, const Size_type reserve0) {
308 (void)type_id;
309 T data;
310 REQUIRE(data.size() == 0);
311
312 if( 0 < reserve0 ) {
313 data.reserve(reserve0);
314 REQUIRE(data.size() == 0);
315 REQUIRE(data.capacity() == reserve0);
316 }
317
319 REQUIRE(data.size() == size0);
320 REQUIRE(data.capacity() >= size0);
321
323 REQUIRE(data.size() == size0);
324 REQUIRE(data.capacity() >= size0);
325
326 data.clear();
327 REQUIRE(data.size() == 0);
328 return data.size() == 0;
329}
330
331template<class T, typename Size_type>
332static bool test_01_seq_fill_list_footprint(const std::string& type_id, const Size_type size0, const Size_type reserve0, const bool do_print_mem) {
333 T data;
334 REQUIRE(0 == data.get_allocator().memory_usage);
335 REQUIRE(data.size() == 0);
336 // if( do_print_mem ) { print_mem(type_id+" 01 (empty)", data); }
337
338 if( 0 < reserve0 ) {
339 data.reserve(reserve0);
340 REQUIRE(data.size() == 0);
341 REQUIRE(0 != data.get_allocator().memory_usage);
342 REQUIRE(data.capacity() == reserve0);
343 }
344
346 REQUIRE(0 != data.get_allocator().memory_usage);
347 REQUIRE(data.size() == size0);
348 REQUIRE(data.capacity() >= size0);
349
351 REQUIRE(0 != data.get_allocator().memory_usage);
352 REQUIRE(data.size() == size0);
353 REQUIRE(data.capacity() >= size0);
354 if( do_print_mem ) { print_mem(type_id+" 01 (full_)", data); }
355
356 data.clear();
357 REQUIRE(data.size() == 0);
358 // if( do_print_mem ) { print_mem(type_id+" 01 (clear)", data); }
359 // REQUIRE(0 == data.get_allocator().memory_usage);
360 return data.size() == 0;
361}
362
363template<class T, typename Size_type>
364static bool test_01_seq_fill_list_itr(const std::string& type_id, const Size_type size0, const Size_type reserve0) {
365 (void)type_id;
366 T data;
367 REQUIRE(data.size() == 0);
368
369 if( 0 < reserve0 ) {
370 data.reserve(reserve0);
371 REQUIRE(data.size() == 0);
372 REQUIRE(data.capacity() == reserve0);
373 }
374
376 REQUIRE(data.size() == size0);
377 REQUIRE(data.capacity() >= size0);
378
380 REQUIRE(data.size() == size0);
381 REQUIRE(data.capacity() >= size0);
382
383 data.clear();
384 REQUIRE(data.size() == 0);
385 return data.size() == 0;
386}
387
388template<class T, typename Size_type>
389static bool test_02_seq_fillunique_find_idx(const std::string& type_id, const Size_type size0, const Size_type reserve0) {
390 (void)type_id;
391 T data;
392 REQUIRE(data.size() == 0);
393
394 if( 0 < reserve0 ) {
395 data.reserve(reserve0);
396 REQUIRE(data.size() == 0);
397 REQUIRE(data.capacity() == reserve0);
398 }
399
401 REQUIRE(data.size() == size0);
402 REQUIRE(data.capacity() >= size0);
403
405 REQUIRE(data.size() == size0);
406 REQUIRE(data.capacity() >= size0);
407
408 data.clear();
409 REQUIRE(data.size() == 0);
410 return data.size() == 0;
411}
412template<class T, typename Size_type>
413static bool test_02_seq_fillunique_find_itr(const std::string& type_id, const Size_type size0, const Size_type reserve0) {
414 (void)type_id;
415 T data;
416 REQUIRE(data.size() == 0);
417
418 if( 0 < reserve0 ) {
419 data.reserve(reserve0);
420 REQUIRE(data.size() == 0);
421 REQUIRE(data.capacity() == reserve0);
422 }
423
425 REQUIRE(data.size() == size0);
426 REQUIRE(data.capacity() >= size0);
427
429 REQUIRE(data.size() == size0);
430 REQUIRE(data.capacity() >= size0);
431
432 data.clear();
433 REQUIRE(data.size() == 0);
434 return data.size() == 0;
435}
436
437/****************************************************************************************
438 ****************************************************************************************/
439
440template<class T, typename Size_type>
441static bool footprint_fillseq_list_itr(const std::string& type_id, const bool do_rserv) {
442 {
443 T data;
444 print_container_info(type_id, data);
445 }
446 // test_01_seq_fill_list_footprint<T, Size_type>(type_id, 25, do_rserv? 25 : 0, true);
447 test_01_seq_fill_list_footprint<T, Size_type>(type_id, 50, do_rserv? 50 : 0, true);
448 if( !catch_auto_run ) {
449 test_01_seq_fill_list_footprint<T, Size_type>(type_id, 100, do_rserv? 100 : 0, true);
450 test_01_seq_fill_list_footprint<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0, true);
451 }
452 return true;
453}
454
455template<class T, typename Size_type>
456static bool benchmark_fillseq_list_idx(const std::string& title_pre, const std::string& type_id,
457 const bool do_rserv) {
458#if RUN_INDEXED_BENCHMARK
459 {
460 T data;
461 print_container_info(title_pre, data);
462 }
463 if( catch_perf_analysis ) {
464 BENCHMARK(title_pre+" FillSeq_List 1000") {
465 return test_01_seq_fill_list_idx<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
466 };
467 return true;
468 }
469 if( catch_auto_run ) {
470 test_01_seq_fill_list_idx<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
471 return true;
472 }
473 // BENCHMARK(title_pre+" FillSeq_List 25") {
474 // return test_01_seq_fill_list_idx<T, Size_type>(type_id, 25, do_rserv? 25 : 0);
475 // };
476 BENCHMARK(title_pre+" FillSeq_List 50") {
477 return test_01_seq_fill_list_idx<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
478 };
479 BENCHMARK(title_pre+" FillSeq_List 100") {
480 return test_01_seq_fill_list_idx<T, Size_type>(type_id, 100, do_rserv? 100 : 0);
481 };
482 BENCHMARK(title_pre+" FillSeq_List 1000") {
483 return test_01_seq_fill_list_idx<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
484 };
485#else
486 (void) title_pre;
487 (void) type_id;
488 (void) do_rserv;
489#endif
490 return true;
491}
492template<class T, typename Size_type>
493static bool benchmark_fillseq_list_itr(const std::string& title_pre, const std::string& type_id,
494 const bool do_rserv) {
495 {
496 T data;
497 print_container_info(title_pre, data);
498 }
499 if( catch_perf_analysis ) {
500 BENCHMARK(title_pre+" FillSeq_List 1000") {
501 return test_01_seq_fill_list_itr<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
502 };
503 // test_01_seq_fill_list_itr<T, Size_type>(type_id, 100000, do_rserv? 100000 : 0);
504 return true;
505 }
506 if( catch_auto_run ) {
507 test_01_seq_fill_list_itr<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
508 return true;
509 }
510 // BENCHMARK(title_pre+" FillSeq_List 25") {
511 // return test_01_seq_fill_list_idx<T, Size_type>(type_id, 25, do_rserv? 25 : 0);
512 // };
513 BENCHMARK(title_pre+" FillSeq_List 50") {
514 return test_01_seq_fill_list_itr<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
515 };
516 BENCHMARK(title_pre+" FillSeq_List 100") {
517 return test_01_seq_fill_list_itr<T, Size_type>(type_id, 100, do_rserv? 100 : 0);
518 };
519 BENCHMARK(title_pre+" FillSeq_List 1000") {
520 return test_01_seq_fill_list_itr<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
521 };
522 return true;
523}
524
525template<class T, typename Size_type>
526static bool benchmark_fillunique_find_idx(const std::string& title_pre, const std::string& type_id,
527 const bool do_rserv) {
528#if RUN_INDEXED_BENCHMARK
529 {
530 T data;
531 print_container_info(title_pre, data);
532 }
533 if( catch_perf_analysis ) {
534 BENCHMARK(title_pre+" FillUni_List 1000") {
535 return test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
536 };
537 return true;
538 }
539 if( catch_auto_run ) {
540 test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
541 return true;
542 }
543 // BENCHMARK(title_pre+" FillUni_List 25") {
544 // return test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 25, do_rserv? 25 : 0);
545 // };
546 BENCHMARK(title_pre+" FillUni_List 50") {
547 return test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
548 };
549 BENCHMARK(title_pre+" FillUni_List 100") {
550 return test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 100, do_rserv? 100 : 0);
551 };
552 BENCHMARK(title_pre+" FillUni_List 1000") {
553 return test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
554 };
555#else
556 (void) title_pre;
557 (void) type_id;
558 (void) do_rserv;
559#endif
560 return true;
561}
562template<class T, typename Size_type>
563static bool benchmark_fillunique_find_itr(const std::string& title_pre, const std::string& type_id,
564 const bool do_rserv) {
565 {
566 T data;
567 print_container_info(title_pre, data);
568 }
569 if( catch_perf_analysis ) {
570 BENCHMARK(title_pre+" FillUni_List 1000") {
571 return test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
572 };
573 // test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 100000, do_rserv? 100000 : 0);
574 return true;
575 }
576 if( catch_auto_run ) {
577 test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
578 return true;
579 }
580 // BENCHMARK(title_pre+" FillUni_List 25") {
581 // return test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 25, do_rserv? 25 : 0);
582 // };
583 BENCHMARK(title_pre+" FillUni_List 50") {
584 return test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
585 };
586 BENCHMARK(title_pre+" FillUni_List 100") {
587 return test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 100, do_rserv? 100 : 0);
588 };
589 BENCHMARK(title_pre+" FillUni_List 1000") {
590 return test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
591 };
592 return true;
593}
594
595/****************************************************************************************
596 ****************************************************************************************/
597
598TEST_CASE( "Memory Footprint 01 - Fill Sequential and List", "[datatype][footprint]" ) {
599 if( catch_perf_analysis ) {
600 // footprint_fillseq_list_itr< jau::cow_vector<DataType01, counting_allocator<DataType01>>, std::size_t>("cowstdvec_empty_", false);
601 // footprint_fillseq_list_itr< jau::cow_darray<DataType01, counting_callocator<DataType01>, jau::nsize_t>, jau::nsize_t>("cowdarray_empty_", false);
602 return;
603 }
610
611#if RUN_RESERVE_BENCHMARK
618#endif
619}
620
621TEST_CASE( "Perf Test 01 - Fill Sequential and List, empty and reserve", "[datatype][sequential]" ) {
622 if( catch_perf_analysis ) {
623 // benchmark_fillseq_list_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_empty_itr", "cowstdvec_empty_", false);
624 // benchmark_fillseq_list_itr< jau::darray<DataType01, jau::nsize_t, jau::callocator<DataType01>>, jau::nsize_t>("JAU_DArray_def_empty_itr", "darray_empty_", false);
625 benchmark_fillseq_list_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_empty_itr", "stdvec_empty_", false);
627 benchmark_fillseq_list_itr< jau::darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("JAU_DArray_mmm_empty_itr", "darray_empty_", false);
628#if RUN_RESERVE_BENCHMARK
629 benchmark_fillseq_list_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_rserv_itr", "stdvec_rserv", true);
631 benchmark_fillseq_list_itr< jau::darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("JAU_DArray_mmm_rserv_itr", "darray_rserv", true);
632#endif
633 return;
634 }
635 benchmark_fillseq_list_idx< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_empty_idx", "stdvec_empty_", false);
636 benchmark_fillseq_list_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_empty_itr", "stdvec_empty_", false);
637
639 benchmark_fillseq_list_idx< jau::darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("JAU_DArray_mmm_empty_idx", "darray_empty_", false);
641 benchmark_fillseq_list_itr< jau::darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("JAU_DArray_mmm_empty_itr", "darray_empty_", false);
642
643 benchmark_fillseq_list_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_empty_itr", "cowstdvec_empty_", false);
644
646 benchmark_fillseq_list_itr< jau::cow_darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("COW_DArray_mmm_empty_itr", "cowdarray_empty_", false);
647
648#if RUN_RESERVE_BENCHMARK
649 benchmark_fillseq_list_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_rserv_itr", "stdvec_rserv", true);
651 benchmark_fillseq_list_itr< jau::darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("JAU_DArray_mmm_rserv_itr", "darray_rserv", true);
652 benchmark_fillseq_list_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_rserv_itr", "cowstdvec_rserv", true);
653 benchmark_fillseq_list_itr< jau::cow_darray<DataType01, jau::nsize_t, jau::callocator<DataType01>>, std::size_t>("COW_DArray_def_rserv_itr", "cowdarray_rserv", true);
654 benchmark_fillseq_list_itr< jau::cow_darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, std::size_t>("COW_DArray_mmm_rserv_itr", "cowdarray_rserv", true);
655#endif
656}
657
658TEST_CASE( "Perf Test 02 - Fill Unique and List, empty and reserve", "[datatype][unique]" ) {
659 if( catch_perf_analysis ) {
660 benchmark_fillunique_find_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_empty_itr", "cowstdvec_empty_", false);
662 benchmark_fillunique_find_itr< jau::cow_darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("COW_DArray_mmm_empty_itr", "cowdarray_empty_", false);
663#if RUN_RESERVE_BENCHMARK
664 benchmark_fillunique_find_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_rserv_itr", "cowstdvec_rserv", true);
666 benchmark_fillunique_find_itr< jau::cow_darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("COW_DArray_mmm_rserv_itr", "cowdarray_rserv", true);
667#endif
668 return;
669 }
670 benchmark_fillunique_find_idx< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_empty_idx", "stdvec_empty_", false);
671 benchmark_fillunique_find_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_empty_itr", "stdvec_empty_", false);
672
674 benchmark_fillunique_find_idx< jau::darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("JAU_DArray_mmm_empty_idx", "darray_empty_", false);
676 benchmark_fillunique_find_itr< jau::darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("JAU_DArray_mmm_empty_itr", "darray_empty_", false);
677
678 benchmark_fillunique_find_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_empty_itr", "cowstdvec_empty_", false);
679
681 benchmark_fillunique_find_itr< jau::cow_darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("COW_DArray_mmm_empty_itr", "cowdarray_empty_", false);
682
683#if RUN_RESERVE_BENCHMARK
684 benchmark_fillunique_find_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_rserv_itr", "stdvec_rserv", true);
686 benchmark_fillunique_find_itr< jau::darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("JAU_DArray_mmm_rserv_itr", "darray_rserv", true);
687 benchmark_fillunique_find_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_rserv_itr", "cowstdvec_rserv", true);
689 benchmark_fillunique_find_itr< jau::cow_darray<DataType01, jau::nsize_t, jau::callocator<DataType01>, true /* memmove */>, jau::nsize_t>("COW_DArray_mmm_rserv_itr", "cowdarray_rserv", true);
690#endif
691}
692
int nop() const noexcept
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
Definition int_types.hpp:55
std::string to_decstring(const value_type &v, const char separator=',', const nsize_t width=0) noexcept
Produce a decimal string representation of an integral integer value.
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
Definition backtrace.hpp:32
bool next() noexcept
A simple allocator using POSIX C functions: ::malloc(), ::free() and ::realloc().
template< class T > is_cow_type<T>::value compile-time Type Trait, determining whether the given temp...
template< class T > is_darray_type<T>::value compile-time Type Trait, determining whether the given t...
Definition darray.hpp:1916
static void test_00_seq_fill_unique_idx(T &data, const Size_type size)
static bool test_01_seq_fill_list_footprint(const std::string &type_id, const Size_type size0, const Size_type reserve0, const bool do_print_mem)
static bool test_02_seq_fillunique_find_itr(const std::string &type_id, const Size_type size0, const Size_type reserve0)
static void print_mem(const std::string &pre, const T &data)
static void print_container_info(const std::string &type_id, const Cont &c, std::enable_if_t< jau::is_darray_type< Cont >::value, bool >=true)
static bool benchmark_fillseq_list_itr(const std::string &title_pre, const std::string &type_id, const bool do_rserv)
static bool benchmark_fillseq_list_idx(const std::string &title_pre, const std::string &type_id, const bool do_rserv)
const DataType01 * findDataSet01_idx(T &data, DataType01 const &elem) noexcept
static void test_00_seq_fill_unique_itr(T &data, const Size_type size, std::enable_if_t< is_cow_type< T >::value, bool >=true)
static bool test_01_seq_fill_list_idx(const std::string &type_id, const Size_type size0, const Size_type reserve0)
static void test_00_seq_fill(T &data, const Size_type size)
const DataType01 * findDataSet01_itr(T &data, DataType01 const &elem, std::enable_if_t< is_cow_type< T >::value, bool >=true) noexcept
static int test_00_list_idx(T &data)
static bool benchmark_fillunique_find_itr(const std::string &title_pre, const std::string &type_id, const bool do_rserv)
static uint8_t start_addr_b[]
static void test_00_seq_find_idx(T &data)
static bool equal_comparator(const value_type &a, const value_type &b) noexcept
static bool test_01_seq_fill_list_itr(const std::string &type_id, const Size_type size0, const Size_type reserve0)
static bool benchmark_fillunique_find_idx(const std::string &title_pre, const std::string &type_id, const bool do_rserv)
static bool footprint_fillseq_list_itr(const std::string &type_id, const bool do_rserv)
static int test_00_list_itr(T &data, std::enable_if_t< is_cow_type< T >::value, bool >=true)
static bool test_02_seq_fillunique_find_idx(const std::string &type_id, const Size_type size0, const Size_type reserve0)
static void test_00_seq_find_itr(T &data)
static Addr48Bit start_addr(start_addr_b)
TEST_CASE("Memory Footprint 01 - Fill Sequential and List", "[datatype][footprint]")
int printf(const char *format,...)
Operating Systems predefined macros.