-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_bench.cpp
1087 lines (993 loc) · 25.1 KB
/
main_bench.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <queue>
#include <utility>
#include <iostream>
#include <chrono>
#include <tuple>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include "vector.hpp"
#include "stack.hpp"
#include "map.hpp"
#include "set.hpp"
#define ADDBENCHMARKFUNC(block1, block2) \
addBenchmarkFuncYouWant(#block1, #block2, block1, block2)
template <typename Func>
class TestRunner {
public:
void addBenchmarkFuncYouWant(std::string block1_name, std::string block2_name,
Func block1, Func block2) {
runnableQueu.push(
std::make_tuple(block1_name, block2_name, block1, block2));
}
void runAll() {
while (!runnableQueu.empty()) {
std::tuple<std::string, std::string, Func, Func> t = runnableQueu.front();
runnableQueu.pop();
std::string b1_name = std::get<0>(t);
std::string b2_name = std::get<1>(t);
Func b1 = std::get<2>(t);
Func b2 = std::get<3>(t);
runSingleFunc(b1_name, b2_name, b1, b2);
}
}
void runSingleFunc(std::string std_block_name, std::string ft_block_name,
Func std_block, Func ft_block) {
// std_blockはstdコンテナの関数を実行するブロック
auto start = std::chrono::steady_clock::now();
std_block();
auto end = std::chrono::steady_clock::now();
std::chrono::duration<double> std_block_erapsed_time = end - start;
// ft_blockはftコンテナの関数を実行するブロック
start = std::chrono::steady_clock::now();
ft_block();
end = std::chrono::steady_clock::now();
std::chrono::duration<double> ft_block_erapsed_time = end - start;
double std_result = std_block_erapsed_time.count();
double ft_result = ft_block_erapsed_time.count();
double performance_ratio = ft_result / std_result;
// ftコンテナライブラリが20倍遅いと許容できない
if (performance_ratio > 20.000) {
std::cerr << "RESULT: \033[31mNG\033[0m"
<< " case: " << std_block_name << ", " << ft_block_name
<< std::endl;
std::cerr << " std: " << std_result << ", ft: " << ft_result
<< " , ratio: " << performance_ratio << std::endl;
} else {
std::cerr << "RESULT: \033[32mOK\033[0m"
<< " case: " << std_block_name << ", " << ft_block_name
<< std::endl;
std::cerr << " std: " << std_result << ", ft: " << ft_result
<< " , ratio: " << performance_ratio << std::endl;
}
}
private:
std::queue<std::tuple<std::string, std::string, Func, Func> > runnableQueu;
};
// test data
ft::vector<int> g_ft_vec(1000000, 42);
std::vector<int> g_std_vec(1000000, 42);
ft::stack<int> g_ft_stack;
std::stack<int> g_std_stack;
ft::map<int, int> g_ft_mp;
std::map<int, int> g_std_mp;
ft::set<int> g_ft_set;
std::set<int> g_std_set;
// --------- vector/construct ---------
void ft_vector_construct() { ft::vector<int> v(1000000, 42); }
void std_vector_construct() { std::vector<int> v(1000000, 42); }
// --------- vector/assign operator ---------
void ft_vector_assign_operator() {
ft::vector<int> v1;
v1 = g_ft_vec;
}
void std_vector_assign_operator() {
std::vector<int> v1;
v1 = g_std_vec;
}
// --------- vector/assign ---------
void ft_vector_assign() {
ft::vector<int> v;
v.assign(1, 10000);
}
void std_vector_assign() {
std::vector<int> v;
v.assign(1, 10000);
}
void ft_vector_assign_1() {
ft::vector<int> v;
v.assign(g_ft_vec.begin(), g_ft_vec.end());
}
void std_vector_assign_1() {
std::vector<int> v;
v.assign(g_std_vec.begin(), g_std_vec.end());
}
// --------- vector/at ---------
void ft_vector_at() {
for (size_t i = 0; i < g_ft_vec.size(); ++i) {
g_ft_vec.at(i);
}
}
void std_vector_at() {
for (size_t i = 0; i < g_std_vec.size(); ++i) {
g_std_vec.at(i);
}
}
// --------- vector/brackets operator ---------
void ft_vector_brackets_operator() {
for (size_t i = 0; i < g_ft_vec.size(); ++i) {
g_ft_vec[i];
}
}
void std_vector_brackets_operator() {
for (size_t i = 0; i < g_std_vec.size(); ++i) {
g_std_vec[i];
}
}
// --------- vector/front ---------
void ft_vector_front() {
for (size_t i = 0; i < g_ft_vec.size(); ++i) {
g_ft_vec.front();
}
}
void std_vector_front() {
for (size_t i = 0; i < g_std_vec.size(); ++i) {
g_std_vec.front();
}
}
// --------- vector/back ---------
void ft_vector_back() {
for (size_t i = 0; i < g_ft_vec.size(); ++i) {
g_ft_vec.back();
}
}
void std_vector_back() {
for (size_t i = 0; i < g_std_vec.size(); ++i) {
g_std_vec.back();
}
}
// --------- vector/data ---------
void ft_vector_data() {
for (size_t i = 0; i < g_ft_vec.size(); ++i) {
g_ft_vec.data();
}
}
void std_vector_data() {
for (size_t i = 0; i < g_std_vec.size(); ++i) {
g_std_vec.data();
}
}
// --------- vector/begin ---------
void ft_vector_begin() {
for (ft::vector<int>::iterator itr = g_ft_vec.begin(); itr != g_ft_vec.end();
++itr) {
}
}
void std_vector_begin() {
for (std::vector<int>::iterator itr = g_std_vec.begin();
itr != g_std_vec.end(); ++itr) {
}
}
// --------- vector/empty ---------
void ft_vector_empty() {
for (size_t i = 0; i < g_ft_vec.size(); ++i) {
g_ft_vec.empty();
}
}
void std_vector_empty() {
for (size_t i = 0; i < g_std_vec.size(); ++i) {
g_std_vec.empty();
}
}
// --------- vector/size ---------
void ft_vector_size() {
for (size_t i = 0; i < g_ft_vec.size(); ++i) {
g_ft_vec.size();
}
}
void std_vector_size() {
for (size_t i = 0; i < g_std_vec.size(); ++i) {
g_std_vec.size();
}
}
// --------- vector/max_size ---------
void ft_vector_max_size() {
for (size_t i = 0; i < g_ft_vec.size(); ++i) {
g_ft_vec.max_size();
}
}
void std_vector_max_size() {
for (size_t i = 0; i < g_std_vec.size(); ++i) {
g_std_vec.max_size();
}
}
// --------- vector/reserve ---------
void ft_vector_reserve() {
ft::vector<int> v;
for (int i = 0; i < 100000; ++i) {
v.reserve(i);
}
}
void std_vector_reserve() {
std::vector<int> v;
for (int i = 0; i < 100000; ++i) {
v.reserve(i);
}
}
// --------- vector/capacity ---------
void ft_vector_capacity() {
for (size_t i = 0; i < g_ft_vec.size(); ++i) {
g_ft_vec.capacity();
}
}
void std_vector_capacity() {
for (size_t i = 0; i < g_std_vec.size(); ++i) {
g_std_vec.capacity();
}
}
// --------- vector/clear ---------
void ft_vector_clear() {
ft::vector<int> v;
v.assign(1, 10000);
v.clear();
}
void std_vector_clear() {
std::vector<int> v;
v.assign(1, 10000);
v.clear();
}
// --------- vector/insert ---------
void ft_vector_insert() {
ft::vector<int> v;
v.insert(v.begin(), 10000, 42);
}
void std_vector_insert() {
std::vector<int> v;
v.insert(v.begin(), 10000, 42);
}
void ft_vector_insert_1() {
ft::vector<int> v;
for (int i = 0; i < 10000; ++i) {
v.insert(v.begin(), i);
}
}
void std_vector_insert_1() {
std::vector<int> v;
for (int i = 0; i < 10000; ++i) {
v.insert(v.begin(), i);
}
}
// --------- vector/erase ---------
void ft_vector_erase() {
ft::vector<int> v;
v.insert(v.begin(), 10000, 42);
v.erase(v.begin(), v.end());
}
void std_vector_erase() {
std::vector<int> v;
v.insert(v.begin(), 10000, 42);
v.erase(v.begin(), v.end());
}
void ft_vector_erase_1() {
ft::vector<int> v;
v.insert(v.begin(), 10000, 42);
for (size_t i = 0; i < v.size(); ++i) {
v.erase(v.begin());
}
}
void std_vector_erase_1() {
std::vector<int> v;
v.insert(v.begin(), 10000, 42);
for (size_t i = 0; i < v.size(); ++i) {
v.erase(v.begin());
}
}
// --------- vector/push_back ---------
void ft_vector_push_back() {
ft::vector<int> v;
for (int i = 0; i < 10000; ++i) {
v.push_back(i);
}
}
void std_vector_push_back() {
std::vector<int> v;
for (int i = 0; i < 10000; ++i) {
v.push_back(i);
}
}
// --------- vector/pop_back ---------
void ft_vector_pop_back() {
ft::vector<int> v;
v.assign(10000, 42);
while (!v.empty()) {
v.pop_back();
}
}
void std_vector_pop_back() {
std::vector<int> v;
v.assign(10000, 42);
while (!v.empty()) {
v.pop_back();
}
}
// --------- vector/resize ---------
void ft_vector_resize() {
ft::vector<int> v;
for (int i = 0; i < 10000; ++i) {
v.resize(i);
}
}
void std_vector_resize() {
std::vector<int> v;
for (int i = 0; i < 10000; ++i) {
v.resize(i);
}
}
// --------- vector/swap ---------
void ft_vector_swap() {
ft::vector<int> v;
v.assign(1000000, 42);
ft::vector<int> v2;
v2.assign(42, 10000);
v.swap(v2);
}
void std_vector_swap() {
std::vector<int> v;
v.assign(1000000, 42);
std::vector<int> v2;
v2.assign(42, 10000);
v.swap(v2);
}
// --------- stack/construct ---------
void ft_stack_construct() { ft::stack<int> s(g_ft_stack); }
void std_stack_construct() { std::stack<int> s(g_std_stack); }
void ft_stack_construct_1() {
ft::stack<int> s;
s = g_ft_stack;
}
void std_stack_construct_1() {
std::stack<int> s;
s = g_std_stack;
}
// --------- stack/top ---------
void ft_stack_top() {
for (int i = 0; i < 100000; ++i) {
g_ft_stack.top();
}
}
void std_stack_top() {
for (int i = 0; i < 100000; ++i) {
g_std_stack.top();
}
}
// --------- stack/empty ---------
void ft_stack_empty() {
for (int i = 0; i < 100000; ++i) {
g_ft_stack.empty();
}
}
void std_stack_empty() {
for (int i = 0; i < 100000; ++i) {
g_std_stack.empty();
}
}
// --------- stack/size ---------
void ft_stack_size() {
for (int i = 0; i < 100000; ++i) {
g_ft_stack.size();
}
}
void std_stack_size() {
for (int i = 0; i < 100000; ++i) {
g_std_stack.size();
}
}
// --------- stack/push ---------
void ft_stack_push() {
ft::stack<int> s;
for (int i = 0; i < 100000; ++i) {
s.push(i);
}
}
void std_stack_push() {
std::stack<int> s;
for (int i = 0; i < 100000; ++i) {
s.push(i);
}
}
// --------- stack/pop ---------
void ft_stack_pop() {
for (int i = 0; i < 100000; ++i) {
g_ft_stack.pop();
}
}
void std_stack_pop() {
for (int i = 0; i < 100000; ++i) {
g_std_stack.pop();
}
}
// --------- map/construct ---------
void ft_map_construct() { ft::map<int, int> m(g_ft_mp.begin(), g_ft_mp.end()); }
void std_map_construct() {
std::map<int, int> m(g_std_mp.begin(), g_std_mp.end());
}
void ft_map_construct_1() { ft::map<int, int> m(g_ft_mp); }
void std_map_construct_1() { std::map<int, int> m(g_std_mp); }
// --------- map/assign_operator ---------
void ft_map_assign_operator() {
ft::map<int, int> m;
m = g_ft_mp;
}
void std_map_assign_operator() {
std::map<int, int> m;
m = g_std_mp;
}
// --------- map/at ---------
void ft_map_at() {
for (int i = 0; i < 100000; ++i) {
g_ft_mp.at(i);
}
}
void std_map_at() {
for (int i = 0; i < 100000; ++i) {
g_std_mp.at(i);
}
}
// --------- map/bracket_operator ---------
void ft_map_bracket_operator() {
for (int i = 0; i < 100000; ++i) {
g_ft_mp[i];
}
}
void std_map_bracket_operator() {
for (int i = 0; i < 100000; ++i) {
g_std_mp[i];
}
}
// --------- map/iterator ---------
void ft_map_iterator() {
for (ft::map<int, int>::iterator itr = g_ft_mp.begin(); itr != g_ft_mp.end();
++itr) {
}
}
void std_map_iterator() {
for (std::map<int, int>::iterator itr = g_std_mp.begin();
itr != g_std_mp.end(); ++itr) {
}
}
void ft_map_iterator_1() {
for (ft::map<int, int>::reverse_iterator itr = g_ft_mp.rbegin();
itr != g_ft_mp.rend(); ++itr) {
}
}
void std_map_iterator_1() {
for (std::map<int, int>::reverse_iterator itr = g_std_mp.rbegin();
itr != g_std_mp.rend(); ++itr) {
}
}
// --------- map/empty ---------
void ft_map_empty() {
for (int i = 0; i < 100000; ++i) {
g_ft_mp.empty();
}
}
void std_map_empty() {
for (int i = 0; i < 100000; ++i) {
g_std_mp.empty();
}
}
// --------- map/size ---------
void ft_map_size() {
for (int i = 0; i < 100000; ++i) {
g_ft_mp.size();
}
}
void std_map_size() {
for (int i = 0; i < 100000; ++i) {
g_std_mp.size();
}
}
// --------- map/max_size ---------
void ft_map_max_size() {
for (int i = 0; i < 100000; ++i) {
g_ft_mp.max_size();
}
}
void std_map_max_size() {
for (int i = 0; i < 100000; ++i) {
g_std_mp.max_size();
}
}
// --------- map/clear ---------
void ft_map_clear() {
ft::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(ft::make_pair(i, i));
}
m.clear();
}
void std_map_clear() {
std::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(std::make_pair(i, i));
}
m.clear();
}
// --------- map/insert ---------
void ft_map_insert() {
ft::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(ft::make_pair(i, i));
}
}
void std_map_insert() {
std::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(std::make_pair(i, i));
}
}
void ft_map_insert_1() {
ft::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(m.begin(), ft::make_pair(i, i));
}
}
void std_map_insert_1() {
std::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(m.begin(), std::make_pair(i, i));
}
}
void ft_map_insert_2() {
ft::map<int, int> m;
m.insert(g_ft_mp.begin(), g_ft_mp.end());
}
void std_map_insert_2() {
std::map<int, int> m;
m.insert(g_std_mp.begin(), g_std_mp.end());
}
// --------- map/erase ---------
void ft_map_erase() {
ft::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(ft::make_pair(i, i));
}
m.erase(m.begin(), m.end());
}
void std_map_erase() {
std::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(std::make_pair(i, i));
}
m.erase(m.begin(), m.end());
}
void ft_map_erase_1() {
ft::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(ft::make_pair(i, i));
}
for (int i = 0; i < 100000; ++i) {
m.erase(m.begin());
}
}
void std_map_erase_1() {
std::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(std::make_pair(i, i));
}
for (int i = 0; i < 100000; ++i) {
m.erase(m.begin());
}
}
void ft_map_erase_2() {
ft::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(ft::make_pair(i, i));
}
for (int i = 0; i < 100000; ++i) {
m.erase(i);
}
}
void std_map_erase_2() {
std::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(std::make_pair(i, i));
}
for (int i = 0; i < 100000; ++i) {
m.erase(i);
}
}
// --------- map/swap ---------
void ft_map_swap() {
ft::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(ft::make_pair(i, i));
}
ft::map<int, int> m2;
m.swap(m2);
}
void std_map_swap() {
std::map<int, int> m;
for (int i = 0; i < 100000; ++i) {
m.insert(std::make_pair(i, i));
}
std::map<int, int> m2;
m.swap(m2);
}
// --------- map/count ---------
void ft_map_count() {
for (int i = 0; i < 100000; ++i) {
g_ft_mp.count(i);
}
}
void std_map_count() {
for (int i = 0; i < 100000; ++i) {
g_std_mp.count(i);
}
}
// --------- map/find ---------
void ft_map_find() {
for (int i = 0; i < 100000; ++i) {
g_ft_mp.find(i);
}
}
void std_map_find() {
for (int i = 0; i < 100000; ++i) {
g_std_mp.find(i);
}
}
// --------- map/equal_range ---------
void ft_map_equal_range() {
for (int i = 0; i < 100000; ++i) {
g_ft_mp.equal_range(i);
}
}
void std_map_equal_range() {
for (int i = 0; i < 100000; ++i) {
g_std_mp.equal_range(i);
}
}
// --------- map/lower_bound ---------
void ft_map_lower_bound() {
for (int i = 0; i < 100000; ++i) {
g_ft_mp.lower_bound(i);
}
}
void std_map_lower_bound() {
for (int i = 0; i < 100000; ++i) {
g_std_mp.lower_bound(i);
}
}
// --------- map/upper_bound ---------
void ft_map_upper_bound() {
for (int i = 0; i < 100000; ++i) {
g_ft_mp.upper_bound(i);
}
}
void std_map_upper_bound() {
for (int i = 0; i < 100000; ++i) {
g_std_mp.upper_bound(i);
}
}
// --------- set/construct ---------
void ft_set_construct() { ft::set<int> s(g_ft_set.begin(), g_ft_set.end()); }
void std_set_construct() {
std::set<int> s(g_std_set.begin(), g_std_set.end());
}
void ft_set_construct_1() { ft::set<int> s(g_ft_set); }
void std_set_construct_1() { std::set<int> s(g_std_set); }
void ft_set_construct_2() {
ft::set<int> s;
s = g_ft_set;
}
void std_set_construct_2() {
std::set<int> s;
s = g_std_set;
}
// --------- set/iterator ---------
void ft_set_iterator() {
for (ft::set<int>::iterator itr = g_ft_set.begin(); itr != g_ft_set.end();
++itr) {
}
}
void std_set_iterator() {
for (std::set<int>::iterator itr = g_std_set.begin(); itr != g_std_set.end();
++itr) {
}
}
void ft_set_iterator_1() {
for (ft::set<int>::reverse_iterator itr = g_ft_set.rbegin();
itr != g_ft_set.rend(); ++itr) {
}
}
void std_set_iterator_1() {
for (std::set<int>::reverse_iterator itr = g_std_set.rbegin();
itr != g_std_set.rend(); ++itr) {
}
}
// --------- set/empty ---------
void ft_set_empty() {
for (int i = 0; i < 100000; ++i) {
g_ft_set.empty();
}
}
void std_set_empty() {
for (int i = 0; i < 100000; ++i) {
g_std_set.empty();
}
}
// --------- set/size ---------
void ft_set_size() {
for (int i = 0; i < 100000; ++i) {
g_ft_set.size();
}
}
void std_set_size() {
for (int i = 0; i < 100000; ++i) {
g_std_set.size();
}
}
// --------- set/clear ---------
void ft_set_clear() {
ft::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
s.clear();
}
void std_set_clear() {
std::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
s.clear();
}
// --------- set/insert ---------
void ft_set_insert() {
ft::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
}
void std_set_insert() {
std::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
}
void ft_set_insert_1() {
ft::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(s.begin(), i);
}
}
void std_set_insert_1() {
std::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(s.begin(), i);
}
}
void ft_set_insert_2() {
ft::set<int> s;
s.insert(g_ft_set.begin(), g_ft_set.end());
}
void std_set_insert_2() {
std::set<int> s;
s.insert(g_std_set.begin(), g_std_set.end());
}
// --------- set/erase ---------
void ft_set_erase() {
ft::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
s.erase(s.begin(), s.end());
}
void std_set_erase() {
std::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
s.erase(s.begin(), s.end());
}
void ft_set_erase_1() {
ft::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
for (int i = 0; i < 100000; ++i) {
s.erase(s.begin());
}
}
void std_set_erase_1() {
std::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
for (int i = 0; i < 100000; ++i) {
s.erase(s.begin());
}
}
void ft_set_erase_2() {
ft::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
for (int i = 0; i < 100000; ++i) {
s.erase(i);
}
}
void std_set_erase_2() {
std::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
for (int i = 0; i < 100000; ++i) {
s.erase(i);
}
}
// --------- set/swap ---------
void ft_set_swap() {
ft::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
ft::set<int> s2;
s.swap(s2);
}
void std_set_swap() {
std::set<int> s;
for (int i = 0; i < 100000; ++i) {
s.insert(i);
}
std::set<int> s2;
s.swap(s2);
}
// --------- set/count ---------
void ft_set_count() {
for (int i = 0; i < 100000; ++i) {
g_ft_set.count(i);
}
}
void std_set_count() {
for (int i = 0; i < 100000; ++i) {
g_std_set.count(i);
}
}
// --------- set/find ---------
void ft_set_find() {
for (int i = 0; i < 100000; ++i) {
g_ft_set.find(i);
}
}
void std_set_find() {
for (int i = 0; i < 100000; ++i) {
g_std_set.find(i);
}
}
// --------- set/equal_range ---------
void ft_set_equal_range() {
for (int i = 0; i < 100000; ++i) {
g_ft_set.equal_range(i);
}
}
void std_set_equal_range() {
for (int i = 0; i < 100000; ++i) {
g_std_set.equal_range(i);
}
}
// --------- set/lower_bound ---------
void ft_set_lower_bound() {
for (int i = 0; i < 100000; ++i) {
g_ft_set.lower_bound(i);
}
}
void std_set_lower_bound() {
for (int i = 0; i < 100000; ++i) {
g_std_set.lower_bound(i);
}
}
// --------- set/upper_bound ---------
void ft_set_upper_bound() {
for (int i = 0; i < 100000; ++i) {
g_ft_set.upper_bound(i);
}
}
void std_set_upper_bound() {
for (int i = 0; i < 100000; ++i) {
g_std_set.upper_bound(i);
}
}
typedef void (*testRunnable)();
int main() {
for (int i = 0; i < 1000000; ++i) {
g_ft_stack.push(i);
g_std_stack.push(i);
g_ft_mp.insert(ft::pair<int, int>(i, i));
g_std_mp.insert(std::pair<int, int>(i, i));
g_ft_set.insert(i);
g_std_set.insert(i);
}
TestRunner<testRunnable> runner;