i32
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "tests.h"
|
||||
|
||||
int main(){
|
||||
i32 main(){
|
||||
if(!setlocale(LC_ALL, "C.UTF8"))
|
||||
kprintf("\e[93msetlocale failed\n");
|
||||
ktDescriptors_beginInit();
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
#include "../src/Autoarr/Autoarr.h"
|
||||
#include <vector>
|
||||
|
||||
int64 _autoarrVsVector(uint16 blockCount, uint16 blockLength){
|
||||
uint32 count=blockLength*blockCount;
|
||||
kprintf("\e[94mblock count: %u block length: %u count: " IFWIN("%llu", "%lu") "\n", blockCount, blockLength, (uint64)count);
|
||||
Autoarr_int64* ar=Autoarr_create(int64, blockCount, blockLength);
|
||||
std::vector<int64> vec=std::vector<int64>();
|
||||
i64 _autoarrVsVector(u16 blockCount, u16 blockLength){
|
||||
u32 count=blockLength*blockCount;
|
||||
kprintf("\e[94mblock count: %u block length: %u count: " IFWIN("%llu", "%lu") "\n", blockCount, blockLength, (u64)count);
|
||||
Autoarr_i64* ar=Autoarr_create(i64, blockCount, blockLength);
|
||||
std::vector<i64> vec=std::vector<i64>();
|
||||
optime("Autoarr_add", count,
|
||||
Autoarr_add(ar, op_i));
|
||||
optime("vector_push_back", count,
|
||||
vec.push_back(op_i));
|
||||
int64 t=0;
|
||||
i64 t=0;
|
||||
optime("Autoarr_get", count,
|
||||
t=Autoarr_get(ar, op_i));
|
||||
optime("vector_get", count,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "tests.h"
|
||||
#include "../src/Autoarr/Autoarr.h"
|
||||
|
||||
static void printautoarr(Autoarr(uint16)* ar){
|
||||
kprintf("\e[94mAutoarr(uint16): "
|
||||
static void printautoarr(Autoarr(u16)* ar){
|
||||
kprintf("\e[94mAutoarr(u16): "
|
||||
IFWIN("%llu", "%lu")
|
||||
"\n max_blocks_count: %u\n"
|
||||
" blocks_count: %u\n"
|
||||
@@ -10,7 +10,7 @@ static void printautoarr(Autoarr(uint16)* ar){
|
||||
" block_length: %u\n"
|
||||
" max_length: %u\n"
|
||||
" length: %u\n",
|
||||
sizeof(Autoarr(uint16)),
|
||||
sizeof(Autoarr(u16)),
|
||||
ar->max_blocks_count,
|
||||
ar->blocks_count,
|
||||
ar->max_block_length,
|
||||
@@ -19,18 +19,18 @@ static void printautoarr(Autoarr(uint16)* ar){
|
||||
Autoarr_length(ar));
|
||||
}
|
||||
|
||||
static void fillar(Autoarr(uint16)* ar){
|
||||
for (uint16 i=0;i<Autoarr_max_length(ar);i++)
|
||||
static void fillar(Autoarr(u16)* ar){
|
||||
for (u16 i=0;i<Autoarr_max_length(ar);i++)
|
||||
Autoarr_add(ar,i);
|
||||
}
|
||||
static void resetar(Autoarr(uint16)* ar){
|
||||
for (uint16 i=0;i<Autoarr_max_length(ar);i++)
|
||||
static void resetar(Autoarr(u16)* ar){
|
||||
for (u16 i=0;i<Autoarr_max_length(ar);i++)
|
||||
Autoarr_set(ar,i,Autoarr_max_length(ar)-i-1);
|
||||
}
|
||||
|
||||
static void printallval(Autoarr(uint16)* ar){
|
||||
static void printallval(Autoarr(u16)* ar){
|
||||
kprintf("\e[90m");
|
||||
for (uint16 i=0;i<Autoarr_length(ar);i++)
|
||||
for (u16 i=0;i<Autoarr_length(ar);i++)
|
||||
kprintf("%u ",Autoarr_get(ar,i));
|
||||
kprintf("\n");
|
||||
}
|
||||
@@ -38,7 +38,7 @@ static void printallval(Autoarr(uint16)* ar){
|
||||
void test_autoarr(){
|
||||
optime("test_autoarr",1,({
|
||||
kprintf("\e[96m------------[test_autoarr]------------\n");
|
||||
Autoarr(uint16)* ar=Autoarr_create(uint16,10,16);
|
||||
Autoarr(u16)* ar=Autoarr_create(u16,10,16);
|
||||
kprintf("\e[92mautoarr created\n");
|
||||
fillar(ar);
|
||||
kprintf("\e[92mautoarr filled up\n");
|
||||
|
||||
@@ -7,8 +7,8 @@ const char text[]=
|
||||
"message: {\n"
|
||||
" bool: false;"
|
||||
" int: -2515;"
|
||||
" uint:#comment!\n 0u;"
|
||||
" double: 965.557f;#another comment!\n"
|
||||
" u:#comment!\n 0u;"
|
||||
" f64: 965.557f;#another comment!\n"
|
||||
" text: \"_$\\\"\\\\'''a ыыы000;2;=:%d;```\";\n"
|
||||
" list: [10,20,30,0,0 ];"
|
||||
"};"
|
||||
|
||||
@@ -12,15 +12,15 @@ char data[]="iojihiojopijiugbjmoihftytryfdrh";
|
||||
kprintf("\e[94mfunction: \e[92m" #hashf "\n");\
|
||||
hasht h=0;\
|
||||
optime("speed test", 1, ({\
|
||||
for(uint32 i=0; i<SPEED_TESTS; i++)\
|
||||
for(u32 i=0; i<SPEED_TESTS; i++)\
|
||||
h=hashf(h, data, sizeof(data));\
|
||||
}));\
|
||||
/*kprintf("\e[94mhash of \"\e[90m%s\e[94m\": \e[92m%x\n",data, h);*/\
|
||||
Autoarr(hasht)* hashes=Autoarr_create(hasht,512,32768);\
|
||||
optime("collision test",1,({\
|
||||
uint32 collisions=0;\
|
||||
for(uint64 i=0;i< COLLISION_TESTS;i++){\
|
||||
hasht h=hashb(hashf, (uint8*)&i, sizeof(i));\
|
||||
u32 collisions=0;\
|
||||
for(u64 i=0;i< COLLISION_TESTS;i++){\
|
||||
hasht h=hashb(hashf, (u8*)&i, sizeof(i));\
|
||||
bool col=false;\
|
||||
Autoarr_foreach(hashes,e,({\
|
||||
if(e==h) {\
|
||||
@@ -40,7 +40,7 @@ char data[]="iojihiojopijiugbjmoihftytryfdrh";
|
||||
void test_hash_functions(){
|
||||
optime("test_hash_functions",1,({
|
||||
kprintf("\e[96m--------[test_hash_functions]---------\n");
|
||||
test_hashfunc(uint32, hash_crc32);
|
||||
test_hashfunc(uint32, hash_sdbm32);
|
||||
test_hashfunc(u32, hash_crc32);
|
||||
test_hashfunc(u32, hash_sdbm32);
|
||||
}));
|
||||
}
|
||||
@@ -15,16 +15,16 @@ void print_hashtable(Hashtable* ht){
|
||||
|
||||
void printrowgraph(Hashtable* ht){
|
||||
kprintf("\e[94mrow length graph:\n");
|
||||
uint16 lgs_l=1000;
|
||||
uint32 lgs[lgs_l];
|
||||
for(uint32 i=0; i<lgs_l; i++)
|
||||
u16 lgs_l=1000;
|
||||
u32 lgs[lgs_l];
|
||||
for(u32 i=0; i<lgs_l; i++)
|
||||
lgs[i]=0;
|
||||
for(uint16 h=0;h<Hashtable_height(ht);h++){
|
||||
for(u16 h=0;h<Hashtable_height(ht);h++){
|
||||
Autoarr(KVPair)* ar=ht->rows[h];
|
||||
uint32 l=Autoarr_length(ar);
|
||||
u32 l=Autoarr_length(ar);
|
||||
lgs[l]++;
|
||||
}
|
||||
for(uint32 i=0; i<lgs_l; i++)
|
||||
for(u32 i=0; i<lgs_l; i++)
|
||||
if(lgs[i]>0) {
|
||||
char* str0=char_multiply(' ',i>=100?0:(i>=10?1:2));
|
||||
char* str1=char_multiply(' ',lgs[i]>=100?0:(lgs[i]>=10?1:2));
|
||||
@@ -36,7 +36,7 @@ void printrowgraph(Hashtable* ht){
|
||||
}
|
||||
}
|
||||
|
||||
char* genkey(uint32 i){
|
||||
char* genkey(u32 i){
|
||||
char* key=malloc(12);
|
||||
IFMSC(
|
||||
sprintf_s(key,12,"key_%u",i),
|
||||
@@ -46,13 +46,13 @@ char* genkey(uint32 i){
|
||||
}
|
||||
|
||||
void fill(Hashtable* ht){
|
||||
for(uint32 i=0;i<100000;i++)
|
||||
for(u32 i=0;i<100000;i++)
|
||||
Hashtable_add(ht,genkey(i),UniUInt64(i));
|
||||
}
|
||||
|
||||
Unitype gett(Hashtable* ht){
|
||||
Unitype u;
|
||||
for(uint32 i=0;i<100000;i++){
|
||||
for(u32 i=0;i<100000;i++){
|
||||
char* key=genkey(i);
|
||||
u=Hashtable_get(ht,key);
|
||||
free(key);
|
||||
|
||||
@@ -5,7 +5,7 @@ void test_kprint(){
|
||||
//int
|
||||
kprint(kp_fgCyan|
|
||||
kp_i,-8888, kp_c,' ', kp_i,0, kp_c,' ', kp_i,1234567890987654321LL,kp_s,"\n");
|
||||
//uint
|
||||
//u
|
||||
kprint(kp_fgGreen|
|
||||
kp_u|kp_post,-8888, kp_c|kp_post|kp_upper,' ', kp_u,0, kp_c,' ',
|
||||
kp_u,1234567890987654321LL, kp_c,'\n');
|
||||
@@ -15,7 +15,7 @@ void test_kprint(){
|
||||
kp_f,-1.0f, kp_c,' ', kp_f,0.0f, kp_c,' ', kp_f,1.0f, kp_c,'\n',
|
||||
kp_f|kp_post,0.000020004f, kp_c,' ',
|
||||
kp_f|kp_post|kp_upper,4000.0109f, kp_c,'\n');
|
||||
//double
|
||||
//f64
|
||||
kprint(kp_fgYellowD|
|
||||
kp_f,-4000.0109, kp_c,' ', kp_f,-0.000020004, kp_c,'\n',
|
||||
kp_f,-1.0, kp_c,' ', kp_f,0.0, kp_c,' ', kp_f,1.0, kp_c,'\n',
|
||||
|
||||
@@ -16,13 +16,13 @@ void test_kprint_colors(){
|
||||
/* IFWIN(
|
||||
({
|
||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
for(uint8 col=0; col<255; col++){
|
||||
for(u8 col=0; col<255; col++){
|
||||
SetConsoleTextAttribute(hConsole, col);
|
||||
kprintf("%u ",col);
|
||||
}
|
||||
}),
|
||||
({
|
||||
for(uint8 col=0; col<255; col++)
|
||||
for(u8 col=0; col<255; col++)
|
||||
kprintf("\e[%um%u ", col, col);
|
||||
})
|
||||
);
|
||||
|
||||
@@ -5,18 +5,18 @@
|
||||
#define test_alg(ALG, VALUE_SIZE, EXPECTED_FROM_ZERO){\
|
||||
kprintf("\e[94mrng algorithm: \e[96m" #ALG "\n");\
|
||||
void* s= ALG##_init(0);\
|
||||
uint##VALUE_SIZE r=ALG##_next(s);\
|
||||
u##VALUE_SIZE r=ALG##_next(s);\
|
||||
kprintf("\e[97m next from zero seed:");\
|
||||
if(r!=EXPECTED_FROM_ZERO){\
|
||||
kprintf("\e[91m " IFWIN("%llu\n","%lu\n"), (uint64)r);\
|
||||
kprintf("\e[91m " IFWIN("%llu\n","%lu\n"), (u64)r);\
|
||||
throw(ERR_UNEXPECTEDVAL);\
|
||||
}\
|
||||
kprintf("\e[92m " IFWIN("%llu\n","%lu\n"), (uint64)r);\
|
||||
kprintf("\e[92m " IFWIN("%llu\n","%lu\n"), (u64)r);\
|
||||
ALG##_free(s);\
|
||||
s= ALG##_initFromTime();\
|
||||
r=ALG##_next(s);\
|
||||
ALG##_free(s);\
|
||||
kprintf("\e[97m next from time seed:\e[92m " IFWIN("%llu\n","%lu\n"), (uint64)r);\
|
||||
kprintf("\e[97m next from time seed:\e[92m " IFWIN("%llu\n","%lu\n"), (u64)r);\
|
||||
}
|
||||
|
||||
void test_rng_algorithms(){
|
||||
|
||||
@@ -9,13 +9,13 @@ void printstnode(STNode* node){
|
||||
kprintf("\n");
|
||||
// prints pointers to all existing branches
|
||||
/* kprintf(" branches: %p\n", node->branches);
|
||||
if(node->branches) for(uint8 i=0;i<8;i++){
|
||||
if(node->branches) for(u8 i=0;i<8;i++){
|
||||
kprintf(" \e[90m[%u]=%p\n",i,node->branches[i]);
|
||||
if(node->branches[i])
|
||||
for (uint8 ii = 0; ii < 8; ii++){
|
||||
for (u8 ii = 0; ii < 8; ii++){
|
||||
kprintf(" \e[90m[%u]=%p\n",ii,node->branches[i][ii]);
|
||||
if(node->branches[i][ii])
|
||||
for (uint8 iii = 0; iii < 4; iii++)
|
||||
for (u8 iii = 0; iii < 4; iii++)
|
||||
kprintf(" \e[90m[%u]=%p\n",iii,node->branches[i][ii][iii]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user