forked from mm304321141/zzz_lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
segment_array_test.cpp
59 lines (45 loc) · 1.52 KB
/
segment_array_test.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
#define _SCL_SECURE_NO_WARNINGS
#include "segment_array.h"
#include <chrono>
#include <iostream>
#include <random>
struct segment_char_array_config
{
typedef char value_type;
typedef std::allocator<char> allocator_type;
typedef std::true_type status_type;
enum
{
memory_block_size = 256,
};
};
int main()
{
segment_array<int> arr;
arr.push_back(1);
arr.emplace_front(2);
arr.insert(arr.end(), 10, 10);
arr.resize(10);
auto t = std::chrono::high_resolution_clock::now;
//std::mt19937 mt;
//auto mtr = std::uniform_int_distribution<int>(0, 25);
segment_array_implement<segment_char_array_config> char_arr;
auto b = t();
for(int i = 0; i <= 999999999; ++i)
{
//char_arr.emplace_back("ABCDEFGHIJKLMNOPQRSTUVWXYZ"[mtr(mt)]);
char_arr.emplace_back("ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i % 26]);
}
auto e = t();
std::cout << "time(ms) = " << std::chrono::duration_cast<std::chrono::duration<float, std::milli>>(e - b).count() << std::endl;
std::cout << "inner bound = " << char_arr.status().inner_bound << std::endl;
std::cout << "leaf bound = " << char_arr.status().leaf_bound << std::endl;
std::cout << "inner count = " << char_arr.status().inner_count << std::endl;
std::cout << "leaf count = " << char_arr.status().leaf_count << std::endl;
for(size_t i = 0; i < char_arr.status().level_count.size(); ++i)
{
std::cout << "level count [" << i << "] = " << char_arr.status().level_count[i] << std::endl;
}
system("pause");
}