Browse Source

feat: benchmark for 10-bits offset list

master
Dnomd343 2 years ago
parent
commit
8d6fe9a6a1
  1. 37
      src/main.cc
  2. 119
      src/short_code/convert.cc
  3. 48
      src/short_code/data_loader.cc
  4. 131
      src/short_code/offset/basic_ranges_offset.h
  5. 2067
      src/short_code/offset/range_prefix_offset.h
  6. 13
      src/short_code/short_code.h

37
src/main.cc

@ -174,15 +174,17 @@ int main() {
// }
// }
ShortCode::speed_up(ShortCode::FAST);
AllCases::build();
// ShortCode::speed_up(ShortCode::FAST);
// AllCases::build();
BasicRanges::build();
std::vector<uint64_t> all_cases;
for (uint64_t head = 0; head < 16; ++head) {
for (const auto &range : BasicRanges::fetch()) {
for (const auto &range : AllCases::fetch()[head]) {
all_cases.emplace_back(head << 32 | range);
}
}
std::cout << "test data size: " << all_cases.size() << std::endl;
// std::cout << "start benchmark" << std::endl;
auto start_time = clock();
@ -269,18 +271,29 @@ int main() {
// }
// }
for (uint32_t i = 0; i < 29334498; ++i) {
// for (uint32_t i = 0; i < 29334498; ++i) {
// if (ShortCode::fast_encode(ShortCode::fast_decode(i)) != i) {
// std::cout << "error" << std::endl;
// }
// ShortCode::fast_encode_legacy(i);
// ShortCode::fast_decode(i);
ShortCode::fast_encode(all_cases[i]);
// ShortCode::fast_encode(all_cases[i]);
// }
for (uint32_t i = 1000000; i < 1100000; ++i) {
// ShortCode::tiny_decode(i);
// ShortCode::tiny_decode_10b(i);
// ShortCode::tiny_encode(all_cases[i]);
ShortCode::tiny_encode_10b(all_cases[i]);
}
// printf("%09lX\n", ShortCode::tiny_decode(14323231));
// std::cout << ShortCode::tiny_encode_demo(0x6EC0F8800) << std::endl;
// printf("%09lX\n", ShortCode::tiny_decode_10b(14323231));
// std::cout << ShortCode::tiny_encode_10b(0x6EC0F8800) << std::endl;
// auto br = BasicRanges::fetch();
// for (auto &range : br) {
// range = Common::range_reverse(range);
@ -290,8 +303,8 @@ int main() {
/// 1017985: 1000000C
// int sum = 0;
// printf(" ");
// for (uint32_t prefix = 0; prefix < 0x1000; ++prefix) {
// printf("%7td, ", std::lower_bound(br.begin(), br.end(), prefix << 20) - br.begin());
// for (uint32_t prefix = 0; prefix < 0x400; ++prefix) {
// printf("%7td, ", std::lower_bound(br.begin(), br.end(), prefix << 22) - br.begin());
// if (sum++ % 8 == 7) {
// printf("\n ");
// }
@ -300,9 +313,9 @@ int main() {
// for (int head = 0; head < 16; ++head) {
// auto &a = AllCases::fetch()[head];
// printf("\n/// --------------------------------- 0x%X ---------------------------------\n ", head);
// for (uint32_t prefix = 0; prefix < 0x1000; ++prefix) {
// printf("%7td, ", std::lower_bound(a.begin(), a.end(), prefix << 20) - a.begin());
// if (sum++ % 8 == 7 and prefix != 0xFFF) {
// for (uint32_t prefix = 0; prefix < 0x400; ++prefix) {
// printf("%7td, ", std::lower_bound(a.begin(), a.end(), prefix << 22) - a.begin());
// if (sum++ % 8 == 7 and prefix != 0x3FF) {
// printf("\n ");
// }
// }
@ -312,8 +325,8 @@ int main() {
// printf("%09lX\n", ShortCode::fast_decode(14323231));
// std::cout << ShortCode::fast_encode(0x6EC0F8800) << std::endl;
// std::cerr << (clock() - start_time) * 1000 / CLOCKS_PER_SEC << "ms" << std::endl;
std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl;
std::cerr << (clock() - start_time) * 1000 / CLOCKS_PER_SEC << "ms" << std::endl;
// std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl;
// std::cout << "complete benchmark" << std::endl;
// pause();

119
src/short_code/convert.cc

@ -136,10 +136,14 @@ uint64_t ShortCode::tiny_decode(uint32_t short_code) {
return 0; // never reach when input valid
}
#include <iostream>
uint32_t ShortCode::tiny_encode(uint64_t common_code) {
// printf("%09lX\n", common_code);
// uint64_t raw = common_code;
uint32_t head = common_code >> 32;
uint32_t prefix = (common_code >> 20) & 0xFFF;
@ -149,15 +153,36 @@ uint32_t ShortCode::tiny_encode(uint64_t common_code) {
uint32_t offset = 0;
auto target = Common::range_reverse((uint32_t)common_code); // target range
// printf("target range: %08X\n", target);
// printf("start search at %d\n", BASIC_RANGES_OFFSET[prefix]);
//
const auto &basic_ranges = BasicRanges::fetch();
// auto true_index = std::find(basic_ranges.begin(), basic_ranges.end(), 0x0FF00F34) - basic_ranges.begin();
// printf("true index: %td\n", true_index);
// printf("basic_ranges[1294828] = %08X\n", basic_ranges[1294828]);
for (auto index = BASIC_RANGES_OFFSET[prefix]; index < basic_ranges.size(); ++index) { // traverse basic ranges
uint32_t range = basic_ranges[index];
// bool flag = false;
// if (range == 0x0FF00F34) {
// flag = true;
// std::cout << "get target range" << std::endl;
// std::cout << "check result -> " << Common::check_case(head, range) << std::endl;
// }
// TODO: using Common::check_range
if (Common::check_case(head, range)) { // search for valid cases
// if (flag) {
// std::cout << "check ok" << std::endl;
// }
if (range == target) { // found target range
// std::cout << "sum = " << sum << std::endl;
return ALL_CASES_OFFSET[head] + RANGE_PREFIX_OFFSET[head][prefix] + offset;
}
@ -169,6 +194,100 @@ uint32_t ShortCode::tiny_encode(uint64_t common_code) {
}
// std::cout << "sum = " << sum << std::endl;
// printf("error common code -> %09lX\n", raw);
printf("error\n");
return 0;
}
uint64_t ShortCode::tiny_decode_10b(uint32_t short_code) {
/// match head index
auto offset = std::upper_bound( // binary search
ALL_CASES_OFFSET, ALL_CASES_OFFSET + 16, short_code
) - 1;
uint64_t head = offset - ALL_CASES_OFFSET; // head index
short_code -= *offset;
/// match range prefix
offset = std::upper_bound( // binary search
RANGE_PREFIX_OFFSET_10b[head], RANGE_PREFIX_OFFSET_10b[head] + 1024, short_code
) - 1;
uint32_t prefix = offset - RANGE_PREFIX_OFFSET_10b[head]; // range prefix
short_code -= *offset;
/// search target range
const auto &basic_ranges = BasicRanges::fetch();
for (auto index = BASIC_RANGES_OFFSET_10b[prefix]; index < basic_ranges.size(); ++index) {
uint32_t range = basic_ranges[index]; // traverse basic ranges
uint32_t broken = Common::check_range(head, basic_ranges[index]); // check and get broken address
auto range_rev = Common::range_reverse(basic_ranges[index]); // reversed range
if (broken) { // invalid case
auto delta = (uint32_t)1 << (32 - broken * 2); // this --delta--> next possible range
auto next_min = (range_rev & ~(delta - 1)) + delta;
while (Common::range_reverse(basic_ranges[++index]) < next_min); // located next range
--index;
} else {
if (!short_code--) { // short code approximate
/// found target range
return head << 32 | range_rev;
}
}
}
return 0; // never reach when input valid
}
uint32_t ShortCode::tiny_encode_10b(uint64_t common_code) {
// printf("%09lX\n", common_code);
uint32_t head = common_code >> 32;
uint32_t prefix = (common_code >> 22) & 0x3FF;
// printf("head = %d\n", head);
// printf("prefix = %X\n", prefix);
uint32_t offset = 0;
auto target = Common::range_reverse((uint32_t)common_code); // target range
const auto &basic_ranges = BasicRanges::fetch();
for (auto index = BASIC_RANGES_OFFSET_10b[prefix]; index < basic_ranges.size(); ++index) { // traverse basic ranges
uint32_t range = basic_ranges[index];
if (Common::check_case(head, range)) { // search for valid cases
if (range == target) { // found target range
return ALL_CASES_OFFSET[head] + RANGE_PREFIX_OFFSET_10b[head][prefix] + offset;
}
++offset; // record sub offset
}
}
return 0;
}

48
src/short_code/data_loader.cc

@ -3,19 +3,19 @@
#include "basic_ranges.h"
#include "short_code_mark.h"
std::mutex ShortCode::map_building;
//std::mutex ShortCode::map_building;
bool ShortCode::fast_mode_available = false;
bool ShortCode::normal_mode_available = false;
std::vector<uint64_t> ShortCode::all_cases_list;
std::unordered_map<uint64_t, uint32_t> ShortCode::all_cases_dict;
//std::vector<uint64_t> ShortCode::all_cases_list;
//std::unordered_map<uint64_t, uint32_t> ShortCode::all_cases_dict;
void ShortCode::speed_up(ShortCode::Mode mode) {
if (fast_mode_available) {
return; // fast mode already available
}
if (mode == ShortCode::FAST) { // build fast mode data
build_mappings();
// build_mappings();
// TODO: confirm AllCases data available
AllCases::build();
@ -38,27 +38,27 @@ ShortCode::Mode ShortCode::check_mode() { // ensure speed up enabled and return
}
/// ensure that fast_mode_available == false
void ShortCode::build_mappings() { // build fast search mappings
if (map_building.try_lock()) { // lock success -> start building
for (int head = 0; head < 16; ++head) {
uint64_t prefix = (uint64_t)head << 32;
for (const auto &range : AllCases::fetch()[head]) { // blocking function
all_cases_list.emplace_back(prefix | range); // short_code -> common_code
}
}
for (int index = 0; index < all_cases_list.size(); ++index) {
all_cases_dict[all_cases_list[index]] = index; // common_code -> short_code
}
fast_mode_available = true; // set available flag
} else { // another thread building
map_building.lock(); // blocking waiting
}
map_building.unlock();
}
//void ShortCode::build_mappings() { // build fast search mappings
// if (map_building.try_lock()) { // lock success -> start building
// for (int head = 0; head < 16; ++head) {
// uint64_t prefix = (uint64_t)head << 32;
// for (const auto &range : AllCases::fetch()[head]) { // blocking function
// all_cases_list.emplace_back(prefix | range); // short_code -> common_code
// }
// }
// for (int index = 0; index < all_cases_list.size(); ++index) {
// all_cases_dict[all_cases_list[index]] = index; // common_code -> short_code
// }
// fast_mode_available = true; // set available flag
// } else { // another thread building
// map_building.lock(); // blocking waiting
// }
// map_building.unlock();
//}
uint32_t ShortCode::fast_encode_legacy(uint64_t common_code) {
return all_cases_dict[common_code];
}
//uint32_t ShortCode::fast_encode_legacy(uint64_t common_code) {
// return all_cases_dict[common_code];
//}
#include <algorithm>

131
src/short_code/offset/basic_ranges_offset.h

@ -2,6 +2,137 @@
#include <cstdint>
const uint32_t BASIC_RANGES_OFFSET_10b[1024] = {
0, 49920, 68192, 86464, 136384, 154656, 161344, 168032,
186304, 204576, 211264, 217952, 236224, 286144, 304416, 322688,
372608, 390880, 397568, 404256, 422528, 429216, 431664, 434112,
440800, 447488, 449936, 452384, 459072, 477344, 484032, 490720,
508992, 527264, 533952, 540640, 558912, 565600, 568048, 570496,
577184, 583872, 586320, 588768, 595456, 613728, 620416, 627104,
645376, 695296, 713568, 731840, 781760, 800032, 806720, 813408,
831680, 849952, 856640, 863328, 881600, 931520, 949792, 968064,
1017984, 1036256, 1042944, 1049632, 1067904, 1074592, 1077040, 1079488,
1086176, 1092864, 1095312, 1097760, 1104448, 1122720, 1129408, 1136096,
1154368, 1161056, 1163504, 1165952, 1172640, 1175088, 1175899, 1176710,
1178987, 1181435, 1182246, 1183057, 1185334, 1192022, 1194299, 1196576,
1202923, 1209611, 1212059, 1214507, 1221195, 1223643, 1224454, 1225265,
1227542, 1229990, 1230801, 1231612, 1233889, 1240577, 1242854, 1245131,
1251478, 1269750, 1276438, 1283126, 1301398, 1308086, 1310363, 1312640,
1318987, 1325675, 1327952, 1330229, 1336576, 1354848, 1361195, 1367542,
1385131, 1403403, 1410091, 1416779, 1435051, 1441739, 1444187, 1446635,
1453323, 1460011, 1462459, 1464907, 1471595, 1489867, 1496555, 1503243,
1521515, 1528203, 1530651, 1533099, 1539787, 1542235, 1543046, 1543857,
1546134, 1548582, 1549393, 1550204, 1552481, 1559169, 1561446, 1563723,
1570070, 1576758, 1579206, 1581654, 1588342, 1590790, 1591601, 1592412,
1594689, 1597137, 1597948, 1598759, 1601036, 1607724, 1610001, 1612278,
1618625, 1636897, 1643585, 1650273, 1668545, 1675233, 1677510, 1679787,
1686134, 1692822, 1695099, 1697376, 1703723, 1721995, 1728342, 1734689,
1752278, 1802198, 1820470, 1838742, 1888662, 1906934, 1913622, 1920310,
1938582, 1956854, 1963542, 1970230, 1988502, 2038422, 2056694, 2074966,
2124886, 2143158, 2149846, 2156534, 2174806, 2181494, 2183771, 2186048,
2192395, 2199083, 2201360, 2203637, 2209984, 2228256, 2234603, 2240950,
2258539, 2276811, 2283499, 2290187, 2308459, 2315147, 2317424, 2319701,
2326048, 2332736, 2335013, 2337290, 2343637, 2361909, 2368256, 2374603,
2392192, 2442112, 2460384, 2478656, 2528576, 2546848, 2553195, 2559542,
2577131, 2595403, 2601750, 2608097, 2625686, 2675606, 2693195, 2710784,
2759339, 2777611, 2784299, 2790987, 2809259, 2815947, 2818395, 2820843,
2827531, 2834219, 2836667, 2839115, 2845803, 2864075, 2870763, 2877451,
2895723, 2902411, 2904859, 2907307, 2913995, 2916443, 2917254, 2918065,
2920342, 2922790, 2923601, 2924412, 2926689, 2933377, 2935654, 2937931,
2944278, 2950966, 2953414, 2955862, 2962550, 2964998, 2965809, 2966620,
2968897, 2971345, 2972156, 2972967, 2975244, 2981932, 2984209, 2986486,
2992833, 3011105, 3017793, 3024481, 3042753, 3049441, 3051718, 3053995,
3060342, 3067030, 3069307, 3071584, 3077931, 3096203, 3102550, 3108897,
3126486, 3133174, 3135622, 3138070, 3144758, 3147206, 3148017, 3148828,
3151105, 3153553, 3154364, 3155175, 3157452, 3164140, 3166417, 3168694,
3175041, 3177489, 3178300, 3179111, 3181388, 3182199, 3182390, 3182581,
3183173, 3183984, 3184175, 3184366, 3184958, 3187235, 3187827, 3188419,
3190204, 3192652, 3193463, 3194274, 3196551, 3197362, 3197553, 3197744,
3198336, 3199147, 3199338, 3199529, 3200121, 3202398, 3202990, 3203582,
3205367, 3212055, 3214332, 3216609, 3222956, 3225233, 3225825, 3226417,
3228202, 3230479, 3231071, 3231663, 3233448, 3239795, 3241580, 3243365,
3248611, 3255299, 3257747, 3260195, 3266883, 3269331, 3270142, 3270953,
3273230, 3275678, 3276489, 3277300, 3279577, 3286265, 3288542, 3290819,
3297166, 3299614, 3300425, 3301236, 3303513, 3304324, 3304515, 3304706,
3305298, 3306109, 3306300, 3306491, 3307083, 3309360, 3309952, 3310544,
3312329, 3314777, 3315588, 3316399, 3318676, 3319487, 3319678, 3319869,
3320461, 3321272, 3321463, 3321654, 3322246, 3324523, 3325115, 3325707,
3327492, 3334180, 3336457, 3338734, 3345081, 3347358, 3347950, 3348542,
3350327, 3352604, 3353196, 3353788, 3355573, 3361920, 3363705, 3365490,
3370736, 3389008, 3395696, 3402384, 3420656, 3427344, 3429621, 3431898,
3438245, 3444933, 3447210, 3449487, 3455834, 3474106, 3480453, 3486800,
3504389, 3511077, 3513354, 3515631, 3521978, 3524255, 3524847, 3525439,
3527224, 3529501, 3530093, 3530685, 3532470, 3538817, 3540602, 3542387,
3547633, 3554321, 3556598, 3558875, 3565222, 3567499, 3568091, 3568683,
3570468, 3572745, 3573337, 3573929, 3575714, 3582061, 3583846, 3585631,
3590877, 3609149, 3615496, 3621843, 3639432, 3645779, 3647564, 3649349,
3654595, 3660942, 3662727, 3664512, 3669758, 3687347, 3692593, 3697839,
3713002, 3731274, 3737962, 3744650, 3762922, 3769610, 3772058, 3774506,
3781194, 3787882, 3790330, 3792778, 3799466, 3817738, 3824426, 3831114,
3849386, 3856074, 3858522, 3860970, 3867658, 3870106, 3870917, 3871728,
3874005, 3876453, 3877264, 3878075, 3880352, 3887040, 3889317, 3891594,
3897941, 3904629, 3907077, 3909525, 3916213, 3918661, 3919472, 3920283,
3922560, 3925008, 3925819, 3926630, 3928907, 3935595, 3937872, 3940149,
3946496, 3964768, 3971456, 3978144, 3996416, 4003104, 4005381, 4007658,
4014005, 4020693, 4022970, 4025247, 4031594, 4049866, 4056213, 4062560,
4080149, 4086837, 4089285, 4091733, 4098421, 4100869, 4101680, 4102491,
4104768, 4107216, 4108027, 4108838, 4111115, 4117803, 4120080, 4122357,
4128704, 4131152, 4131963, 4132774, 4135051, 4135862, 4136053, 4136244,
4136836, 4137647, 4137838, 4138029, 4138621, 4140898, 4141490, 4142082,
4143867, 4146315, 4147126, 4147937, 4150214, 4151025, 4151216, 4151407,
4151999, 4152810, 4153001, 4153192, 4153784, 4156061, 4156653, 4157245,
4159030, 4165718, 4167995, 4170272, 4176619, 4178896, 4179488, 4180080,
4181865, 4184142, 4184734, 4185326, 4187111, 4193458, 4195243, 4197028,
4202274, 4208962, 4211410, 4213858, 4220546, 4222994, 4223805, 4224616,
4226893, 4229341, 4230152, 4230963, 4233240, 4239928, 4242205, 4244482,
4250829, 4253277, 4254088, 4254899, 4257176, 4257987, 4258178, 4258369,
4258961, 4259772, 4259963, 4260154, 4260746, 4263023, 4263615, 4264207,
4265992, 4268440, 4269251, 4270062, 4272339, 4273150, 4273341, 4273532,
4274124, 4274935, 4275126, 4275317, 4275909, 4278186, 4278778, 4279370,
4281155, 4287843, 4290120, 4292397, 4298744, 4301021, 4301613, 4302205,
4303990, 4306267, 4306859, 4307451, 4309236, 4315583, 4317368, 4319153,
4324399, 4342671, 4349359, 4356047, 4374319, 4381007, 4383284, 4385561,
4391908, 4398596, 4400873, 4403150, 4409497, 4427769, 4434116, 4440463,
4458052, 4464740, 4467017, 4469294, 4475641, 4477918, 4478510, 4479102,
4480887, 4483164, 4483756, 4484348, 4486133, 4492480, 4494265, 4496050,
4501296, 4507984, 4510261, 4512538, 4518885, 4521162, 4521754, 4522346,
4524131, 4526408, 4527000, 4527592, 4529377, 4535724, 4537509, 4539294,
4544540, 4562812, 4569159, 4575506, 4593095, 4599442, 4601227, 4603012,
4608258, 4614605, 4616390, 4618175, 4623421, 4641010, 4646256, 4651502,
4666665, 4716585, 4734857, 4753129, 4803049, 4821321, 4828009, 4834697,
4852969, 4871241, 4877929, 4884617, 4902889, 4952809, 4971081, 4989353,
5039273, 5057545, 5064233, 5070921, 5089193, 5095881, 5098158, 5100435,
5106782, 5113470, 5115747, 5118024, 5124371, 5142643, 5148990, 5155337,
5172926, 5191198, 5197886, 5204574, 5222846, 5229534, 5231811, 5234088,
5240435, 5247123, 5249400, 5251677, 5258024, 5276296, 5282643, 5288990,
5306579, 5356499, 5374771, 5393043, 5442963, 5461235, 5467582, 5473929,
5491518, 5509790, 5516137, 5522484, 5540073, 5589993, 5607582, 5625171,
5673726, 5691998, 5698686, 5705374, 5723646, 5730334, 5732611, 5734888,
5741235, 5747923, 5750200, 5752477, 5758824, 5777096, 5783443, 5789790,
5807379, 5814067, 5816344, 5818621, 5824968, 5827245, 5827837, 5828429,
5830214, 5832491, 5833083, 5833675, 5835460, 5841807, 5843592, 5845377,
5850623, 5857311, 5859588, 5861865, 5868212, 5870489, 5871081, 5871673,
5873458, 5875735, 5876327, 5876919, 5878704, 5885051, 5886836, 5888621,
5893867, 5912139, 5918486, 5924833, 5942422, 5948769, 5950554, 5952339,
5957585, 5963932, 5965717, 5967502, 5972748, 5990337, 5995583, 6000829,
6015992, 6034264, 6040952, 6047640, 6065912, 6072600, 6074877, 6077154,
6083501, 6090189, 6092466, 6094743, 6101090, 6119362, 6125709, 6132056,
6149645, 6156333, 6158610, 6160887, 6167234, 6169511, 6170103, 6170695,
6172480, 6174757, 6175349, 6175941, 6177726, 6184073, 6185858, 6187643,
6192889, 6199577, 6201854, 6204131, 6210478, 6212755, 6213347, 6213939,
6215724, 6218001, 6218593, 6219185, 6220970, 6227317, 6229102, 6230887,
6236133, 6254405, 6260752, 6267099, 6284688, 6291035, 6292820, 6294605,
6299851, 6306198, 6307983, 6309768, 6315014, 6332603, 6337849, 6343095,
6358258, 6408178, 6426450, 6444722, 6494642, 6512914, 6519261, 6525608,
6543197, 6561469, 6567816, 6574163, 6591752, 6641672, 6659261, 6676850,
6725405, 6743677, 6750024, 6756371, 6773960, 6780307, 6782092, 6783877,
6789123, 6795470, 6797255, 6799040, 6804286, 6821875, 6827121, 6832367,
6847530, 6865802, 6872149, 6878496, 6896085, 6902432, 6904217, 6906002,
6911248, 6917595, 6919380, 6921165, 6926411, 6944000, 6949246, 6954492,
6969655, 7019575, 7037164, 7054753, 7103308, 7120897, 7126143, 7131389,
7146552, 7164141, 7169387, 7174633, 7189796, 7238351, 7253514, 7268677,
};
const uint32_t BASIC_RANGES_OFFSET[4096] = {
0, 18272, 24960, 31648, 49920, 56608, 59056, 61504,
68192, 74880, 77328, 79776, 86464, 104736, 111424, 118112,

2067
src/short_code/offset/range_prefix_offset.h

File diff suppressed because it is too large

13
src/short_code/short_code.h

@ -43,14 +43,17 @@ public:
static uint64_t tiny_decode(uint32_t short_code);
static uint32_t tiny_encode(uint64_t common_code);
static uint64_t tiny_decode_10b(uint32_t short_code);
static uint32_t tiny_encode_10b(uint64_t common_code);
// TODO: ShortCode::create() / ShortCode::from_str(...) / ShortCode::from_common_code(...)
static uint32_t fast_encode_legacy(uint64_t common_code);
// static uint32_t fast_encode_legacy(uint64_t common_code);
private:
uint32_t code;
static std::mutex map_building;
// static std::mutex map_building;
static bool fast_mode_available;
static bool normal_mode_available;
@ -60,10 +63,10 @@ private:
/// for some test, the new function only using < 170MB memory, while the legacy using > 1.5GB
/// but the legacy one is more easy and a little fast.
/// BTW, the new one init less than 1.2s, legacy one need about 15s
static std::vector<uint64_t> all_cases_list; // short_code -> common_code
static std::unordered_map<uint64_t, uint32_t> all_cases_dict; // common_code -> short_code
// static std::vector<uint64_t> all_cases_list; // short_code -> common_code
// static std::unordered_map<uint64_t, uint32_t> all_cases_dict; // common_code -> short_code
static void build_mappings();
// static void build_mappings();
// static uint64_t tiny_decode(uint32_t short_code);
// static uint32_t tiny_encode(uint64_t common_code);
};

Loading…
Cancel
Save