-
Notifications
You must be signed in to change notification settings - Fork 0
/
zGenProcs_tests.cpp
104 lines (82 loc) · 2.63 KB
/
zGenProcs_tests.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
#include "stdafx.h"
#include "zGenProcs.h"
using namespace std;
//------------------------------------------------------------------------------------------
//тестово показать статистику первых пар
void zGenProcs::show_first_pairs_stat()
{
//_load_all_needed();
//__int64 total_sum = 0;
//int total_first = 0;
//int total_and = 0;
//int total_other = 0;
//for(size_t i = 0; i < m_first_pair_vec.size(); i++)
//{
// unsigned int val = m_first_pair_vec[i];
// total_sum += val;
//
// if(val)
// {
// total_first++;
// int word1 = 0, word2 = 0;
// get_words_from_pair(m_pairs_vec[i], word1, word2);
// if(word1 == 0)
// total_and++;
// else
// total_other++;
// }
//}
//string s = zstr::fmt("size=%d, total_first=%d, total_and=%d, total_other=%d",
// (int)m_first_pair_vec.size(), total_first, total_and, total_other);
//zdebug::log()->Log(s);
//zdebug::log()->Log(zstr::fmt("total_sum=%I64d", total_sum));
}
//------------------------------------------------------------------------------------------
//выводит в лог частоту используемости каждого w3db-файла
void zGenProcs::show_w3db_usage()
{
for(int i = 0; i < (int)m_w3db_files.size(); i++)
{
Z_W3DB_FILE &b = m_w3db_files[i];
string msg = zstr::fmt("%02d. %s. usage = %d", i, b.fname.c_str(), b.m_DbgUsage);
zdebug::log()->Log(msg);
}
}
//------------------------------------------------------------------------------------------
void zGenProcs::clear_w3db_usage()
{
for(int i = 0; i < (int)m_w3db_files.size(); i++)
m_w3db_files[i].m_DbgUsage = 0;
}
//------------------------------------------------------------------------------------------
//тесты скорости некоторых функций
int zGenProcs::test_performance()
{
_load_all_needed();
int ret = 0;
for(int i = 0; i < 200000; i++)
{
int xx = 0 + rand() % (int)m_pairs_vec.size();
__int64 pair_val = m_pairs_vec[xx];
int ind = _get_pair_ind(pair_val);
ret = ind;
if(xx != ind)
rel_assert(0);
}
zdebug::log()->Log("test_performance, " + zdebug::log()->GetLogTimeSpend() + "\n");
return ret;
}
//------------------------------------------------------------------------------------------
void static _test_set_words_to_cache()
{
//m_w3db_cache_.resize(100);
//unsigned char *arr = &m_w3db_cache_[0];
//set_words_to_cache(arr, 1, 2, 3);
//int w1, w2, w3;
//get_words_from_cache(arr, w1, w2, w3);
//m_w3db_cache_.resize(100);
//unsigned char *arr = &m_w3db_cache_[0];
//set_words_to_cache(arr, 0xffffff, 0xfffffe, 0xeffff0);
//int w1, w2, w3;
//get_words_from_cache(arr, w1, w2, w3);
}