Gamp v0.0.8
Gamp: Graphics, Audio, Multimedia and Processing
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 static 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 static 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 static 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 jau_printf("Mem: %s: Elements %'5zu x %zu bytes; %s, %lf ratio\n",
296 pre.c_str(), elements, bytes_element, data.get_allocator().toString(), overhead);
297 // 5: 1,000
298 // 7: 100,000
299 // 9: 1,000,000
300}
301
302/****************************************************************************************
303 ****************************************************************************************/
304
305template<class T, typename Size_type>
306static bool test_01_seq_fill_list_idx(const std::string& type_id, const Size_type size0, const Size_type reserve0) {
307 (void)type_id;
308 T data;
309 REQUIRE(data.size() == 0);
310
311 if( 0 < reserve0 ) {
312 data.reserve(reserve0);
313 REQUIRE(data.size() == 0);
314 REQUIRE(data.capacity() == reserve0);
315 }
316
318 REQUIRE(data.size() == size0);
319 REQUIRE(data.capacity() >= size0);
320
322 REQUIRE(data.size() == size0);
323 REQUIRE(data.capacity() >= size0);
324
325 data.clear();
326 REQUIRE(data.size() == 0);
327 return data.size() == 0;
328}
329
330template<class T, typename Size_type>
331static 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) {
332 T data;
333 REQUIRE(0 == data.get_allocator().memory_usage);
334 REQUIRE(data.size() == 0);
335 // if( do_print_mem ) { print_mem(type_id+" 01 (empty)", data); }
336
337 if( 0 < reserve0 ) {
338 data.reserve(reserve0);
339 REQUIRE(data.size() == 0);
340 REQUIRE(0 != data.get_allocator().memory_usage);
341 REQUIRE(data.capacity() == reserve0);
342 }
343
345 REQUIRE(0 != data.get_allocator().memory_usage);
346 REQUIRE(data.size() == size0);
347 REQUIRE(data.capacity() >= size0);
348
350 REQUIRE(0 != data.get_allocator().memory_usage);
351 REQUIRE(data.size() == size0);
352 REQUIRE(data.capacity() >= size0);
353 if( do_print_mem ) { print_mem(type_id+" 01 (full_)", data); }
354
355 data.clear();
356 REQUIRE(data.size() == 0);
357 // if( do_print_mem ) { print_mem(type_id+" 01 (clear)", data); }
358 // REQUIRE(0 == data.get_allocator().memory_usage);
359 return data.size() == 0;
360}
361
362template<class T, typename Size_type>
363static bool test_01_seq_fill_list_itr(const std::string& type_id, const Size_type size0, const Size_type reserve0) {
364 (void)type_id;
365 T data;
366 REQUIRE(data.size() == 0);
367
368 if( 0 < reserve0 ) {
369 data.reserve(reserve0);
370 REQUIRE(data.size() == 0);
371 REQUIRE(data.capacity() == reserve0);
372 }
373
375 REQUIRE(data.size() == size0);
376 REQUIRE(data.capacity() >= size0);
377
379 REQUIRE(data.size() == size0);
380 REQUIRE(data.capacity() >= size0);
381
382 data.clear();
383 REQUIRE(data.size() == 0);
384 return data.size() == 0;
385}
386
387template<class T, typename Size_type>
388static bool test_02_seq_fillunique_find_idx(const std::string& type_id, const Size_type size0, const Size_type reserve0) {
389 (void)type_id;
390 T data;
391 REQUIRE(data.size() == 0);
392
393 if( 0 < reserve0 ) {
394 data.reserve(reserve0);
395 REQUIRE(data.size() == 0);
396 REQUIRE(data.capacity() == reserve0);
397 }
398
400 REQUIRE(data.size() == size0);
401 REQUIRE(data.capacity() >= size0);
402
404 REQUIRE(data.size() == size0);
405 REQUIRE(data.capacity() >= size0);
406
407 data.clear();
408 REQUIRE(data.size() == 0);
409 return data.size() == 0;
410}
411template<class T, typename Size_type>
412static bool test_02_seq_fillunique_find_itr(const std::string& type_id, const Size_type size0, const Size_type reserve0) {
413 (void)type_id;
414 T data;
415 REQUIRE(data.size() == 0);
416
417 if( 0 < reserve0 ) {
418 data.reserve(reserve0);
419 REQUIRE(data.size() == 0);
420 REQUIRE(data.capacity() == reserve0);
421 }
422
424 REQUIRE(data.size() == size0);
425 REQUIRE(data.capacity() >= size0);
426
428 REQUIRE(data.size() == size0);
429 REQUIRE(data.capacity() >= size0);
430
431 data.clear();
432 REQUIRE(data.size() == 0);
433 return data.size() == 0;
434}
435
436/****************************************************************************************
437 ****************************************************************************************/
438
439template<class T, typename Size_type>
440static bool footprint_fillseq_list_itr(const std::string& type_id, const bool do_rserv) {
441 {
442 T data;
443 print_container_info(type_id, data);
444 }
445 // test_01_seq_fill_list_footprint<T, Size_type>(type_id, 25, do_rserv? 25 : 0, true);
446 test_01_seq_fill_list_footprint<T, Size_type>(type_id, 50, do_rserv? 50 : 0, true);
447 if( !catch_auto_run ) {
448 test_01_seq_fill_list_footprint<T, Size_type>(type_id, 100, do_rserv? 100 : 0, true);
449 test_01_seq_fill_list_footprint<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0, true);
450 }
451 return true;
452}
453
454template<class T, typename Size_type>
455static bool benchmark_fillseq_list_idx(const std::string& title_pre, const std::string& type_id,
456 const bool do_rserv) {
457#if RUN_INDEXED_BENCHMARK
458 {
459 T data;
460 print_container_info(title_pre, data);
461 }
462 if( catch_perf_analysis ) {
463 BENCHMARK(title_pre+" FillSeq_List 1000") {
464 return test_01_seq_fill_list_idx<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
465 };
466 return true;
467 }
468 if( catch_auto_run ) {
469 test_01_seq_fill_list_idx<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
470 return true;
471 }
472 // BENCHMARK(title_pre+" FillSeq_List 25") {
473 // return test_01_seq_fill_list_idx<T, Size_type>(type_id, 25, do_rserv? 25 : 0);
474 // };
475 BENCHMARK(title_pre+" FillSeq_List 50") {
476 return test_01_seq_fill_list_idx<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
477 };
478 BENCHMARK(title_pre+" FillSeq_List 100") {
479 return test_01_seq_fill_list_idx<T, Size_type>(type_id, 100, do_rserv? 100 : 0);
480 };
481 BENCHMARK(title_pre+" FillSeq_List 1000") {
482 return test_01_seq_fill_list_idx<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
483 };
484#else
485 (void) title_pre;
486 (void) type_id;
487 (void) do_rserv;
488#endif
489 return true;
490}
491template<class T, typename Size_type>
492static bool benchmark_fillseq_list_itr(const std::string& title_pre, const std::string& type_id,
493 const bool do_rserv) {
494 {
495 T data;
496 print_container_info(title_pre, data);
497 }
498 if( catch_perf_analysis ) {
499 BENCHMARK(title_pre+" FillSeq_List 1000") {
500 return test_01_seq_fill_list_itr<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
501 };
502 // test_01_seq_fill_list_itr<T, Size_type>(type_id, 100000, do_rserv? 100000 : 0);
503 return true;
504 }
505 if( catch_auto_run ) {
506 test_01_seq_fill_list_itr<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
507 return true;
508 }
509 // BENCHMARK(title_pre+" FillSeq_List 25") {
510 // return test_01_seq_fill_list_idx<T, Size_type>(type_id, 25, do_rserv? 25 : 0);
511 // };
512 BENCHMARK(title_pre+" FillSeq_List 50") {
513 return test_01_seq_fill_list_itr<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
514 };
515 BENCHMARK(title_pre+" FillSeq_List 100") {
516 return test_01_seq_fill_list_itr<T, Size_type>(type_id, 100, do_rserv? 100 : 0);
517 };
518 BENCHMARK(title_pre+" FillSeq_List 1000") {
519 return test_01_seq_fill_list_itr<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
520 };
521 return true;
522}
523
524template<class T, typename Size_type>
525static bool benchmark_fillunique_find_idx(const std::string& title_pre, const std::string& type_id,
526 const bool do_rserv) {
527#if RUN_INDEXED_BENCHMARK
528 {
529 T data;
530 print_container_info(title_pre, data);
531 }
532 if( catch_perf_analysis ) {
533 BENCHMARK(title_pre+" FillUni_List 1000") {
534 return test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
535 };
536 return true;
537 }
538 if( catch_auto_run ) {
539 test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
540 return true;
541 }
542 // BENCHMARK(title_pre+" FillUni_List 25") {
543 // return test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 25, do_rserv? 25 : 0);
544 // };
545 BENCHMARK(title_pre+" FillUni_List 50") {
546 return test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
547 };
548 BENCHMARK(title_pre+" FillUni_List 100") {
549 return test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 100, do_rserv? 100 : 0);
550 };
551 BENCHMARK(title_pre+" FillUni_List 1000") {
552 return test_02_seq_fillunique_find_idx<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
553 };
554#else
555 (void) title_pre;
556 (void) type_id;
557 (void) do_rserv;
558#endif
559 return true;
560}
561template<class T, typename Size_type>
562static bool benchmark_fillunique_find_itr(const std::string& title_pre, const std::string& type_id,
563 const bool do_rserv) {
564 {
565 T data;
566 print_container_info(title_pre, data);
567 }
568 if( catch_perf_analysis ) {
569 BENCHMARK(title_pre+" FillUni_List 1000") {
570 return test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
571 };
572 // test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 100000, do_rserv? 100000 : 0);
573 return true;
574 }
575 if( catch_auto_run ) {
576 test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
577 return true;
578 }
579 // BENCHMARK(title_pre+" FillUni_List 25") {
580 // return test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 25, do_rserv? 25 : 0);
581 // };
582 BENCHMARK(title_pre+" FillUni_List 50") {
583 return test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 50, do_rserv? 50 : 0);
584 };
585 BENCHMARK(title_pre+" FillUni_List 100") {
586 return test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 100, do_rserv? 100 : 0);
587 };
588 BENCHMARK(title_pre+" FillUni_List 1000") {
589 return test_02_seq_fillunique_find_itr<T, Size_type>(type_id, 1000, do_rserv? 1000 : 0);
590 };
591 return true;
592}
593
594/****************************************************************************************
595 ****************************************************************************************/
596
597TEST_CASE( "Memory Footprint 01 - Fill Sequential and List", "[datatype][footprint]" ) {
598 if( catch_perf_analysis ) {
599 // footprint_fillseq_list_itr< jau::cow_vector<DataType01, counting_allocator<DataType01>>, std::size_t>("cowstdvec_empty_", false);
600 // footprint_fillseq_list_itr< jau::cow_darray<DataType01, counting_callocator<DataType01>, jau::nsize_t>, jau::nsize_t>("cowdarray_empty_", false);
601 return;
602 }
609
610#if RUN_RESERVE_BENCHMARK
617#endif
618}
619
620TEST_CASE( "Perf Test 01 - Fill Sequential and List, empty and reserve", "[datatype][sequential]" ) {
621 if( catch_perf_analysis ) {
622 // benchmark_fillseq_list_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_empty_itr", "cowstdvec_empty_", false);
623 // benchmark_fillseq_list_itr< jau::darray<DataType01, jau::nsize_t, jau::callocator<DataType01>>, jau::nsize_t>("JAU_DArray_def_empty_itr", "darray_empty_", false);
624 benchmark_fillseq_list_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_empty_itr", "stdvec_empty_", false);
626 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);
627#if RUN_RESERVE_BENCHMARK
628 benchmark_fillseq_list_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_rserv_itr", "stdvec_rserv", true);
630 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);
631#endif
632 return;
633 }
634 benchmark_fillseq_list_idx< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_empty_idx", "stdvec_empty_", false);
635 benchmark_fillseq_list_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_empty_itr", "stdvec_empty_", false);
636
638 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);
640 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);
641
642 benchmark_fillseq_list_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_empty_itr", "cowstdvec_empty_", false);
643
645 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);
646
647#if RUN_RESERVE_BENCHMARK
648 benchmark_fillseq_list_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_rserv_itr", "stdvec_rserv", true);
650 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);
651 benchmark_fillseq_list_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_rserv_itr", "cowstdvec_rserv", true);
652 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);
653 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);
654#endif
655}
656
657TEST_CASE( "Perf Test 02 - Fill Unique and List, empty and reserve", "[datatype][unique]" ) {
658 if( catch_perf_analysis ) {
659 benchmark_fillunique_find_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_empty_itr", "cowstdvec_empty_", false);
661 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);
662#if RUN_RESERVE_BENCHMARK
663 benchmark_fillunique_find_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_rserv_itr", "cowstdvec_rserv", true);
665 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);
666#endif
667 return;
668 }
669 benchmark_fillunique_find_idx< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_empty_idx", "stdvec_empty_", false);
670 benchmark_fillunique_find_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_empty_itr", "stdvec_empty_", false);
671
673 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);
675 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);
676
677 benchmark_fillunique_find_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_empty_itr", "cowstdvec_empty_", false);
678
680 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);
681
682#if RUN_RESERVE_BENCHMARK
683 benchmark_fillunique_find_itr< std::vector<DataType01, std::allocator<DataType01>>, std::size_t>("STD_Vector_def_rserv_itr", "stdvec_rserv", true);
685 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);
686 benchmark_fillunique_find_itr< jau::cow_vector<DataType01, std::allocator<DataType01>>, std::size_t>("COW_Vector_def_rserv_itr", "cowstdvec_rserv", true);
688 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);
689#endif
690}
691
int nop() const noexcept
#define jau_printf(fmt,...)
Definition debug.hpp:253
uint_bytes_t< sizeof(unsigned long int)> nsize_t
Natural 'size_t' alternative using uint<XX>_t with xx = sizeof(unsigned long int)*8 as its natural si...
Definition int_types.hpp:89
__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:1989
static const DataType01 * findDataSet01_itr(T &data, DataType01 const &elem, std::enable_if_t< is_cow_type< T >::value, bool >=true) noexcept
static const DataType01 * findDataSet01_idx(T &data, DataType01 const &elem) noexcept
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)
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)
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.