optime() macro and gcc -O1
This commit is contained in:
parent
ed10ac273e
commit
a322ee4545
@ -17,7 +17,7 @@ clang: all
|
|||||||
CMPARGS= -Wall $(SRC) -o $(OUTFILE)
|
CMPARGS= -Wall $(SRC) -o $(OUTFILE)
|
||||||
build:
|
build:
|
||||||
@echo "\e[36m-------------[build]---------------\e[0m"
|
@echo "\e[36m-------------[build]---------------\e[0m"
|
||||||
$(CMP) -O2 $(CMPARGS)
|
$(CMP) -O1 -flto $(CMPARGS)
|
||||||
build_dbg:
|
build_dbg:
|
||||||
@echo "\e[36m-------------[build_dbg]---------------\e[0m"
|
@echo "\e[36m-------------[build_dbg]---------------\e[0m"
|
||||||
$(CMP) -O0 $(CMPARGS).dbg
|
$(CMP) -O0 $(CMPARGS).dbg
|
||||||
|
|||||||
@ -6,21 +6,18 @@
|
|||||||
int main(){
|
int main(){
|
||||||
setlocale(LC_ALL, "en-US.Unicode");
|
setlocale(LC_ALL, "en-US.Unicode");
|
||||||
printf("\e[92mdtsod parser in c language!\e[97m\n");
|
printf("\e[92mdtsod parser in c language!\e[97m\n");
|
||||||
//test_all();
|
optime({test_all();});
|
||||||
//test_autoarr2();
|
optime({
|
||||||
long start=clock();
|
|
||||||
Autoarr2(uint64) _ar2=Autoarr2_create(uint64,10000,20000);
|
Autoarr2(uint64) _ar2=Autoarr2_create(uint64,10000,20000);
|
||||||
Autoarr2(uint64)* ar2=&_ar2;
|
Autoarr2(uint64)* ar2=&_ar2;
|
||||||
for(uint32 i=0;i<Autoarr2_max_length(ar2);i++)
|
for(uint32 i=0;i<Autoarr2_max_length(ar2);i++)
|
||||||
Autoarr2_add(ar2,8);
|
Autoarr2_add(ar2,8);
|
||||||
long stop=clock();
|
});
|
||||||
printf("\e[96m%li\n",stop-start);
|
optime({
|
||||||
start=clock();
|
|
||||||
Autoarr _ar=Autoarr_create(10000,20000,UInt64);
|
Autoarr _ar=Autoarr_create(10000,20000,UInt64);
|
||||||
Autoarr* ar=&_ar;
|
Autoarr* ar=&_ar;
|
||||||
for(uint32 i=0;i<ar->max_length;i++)
|
for(uint32 i=0;i<ar->max_length;i++)
|
||||||
Autoarr_add_uint64(ar,8);
|
Autoarr_add_uint64(ar,8);
|
||||||
stop=clock();
|
});
|
||||||
printf("\e[96m%li\n",stop-start);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,8 @@ void printuni(Unitype v){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void test_all(void){
|
void test_all(void){
|
||||||
test_autoarr();
|
|
||||||
test_searchtree();
|
test_searchtree();
|
||||||
|
test_autoarr();
|
||||||
|
test_autoarr2();
|
||||||
printf("\e[96m---------------------------------------\n");
|
printf("\e[96m---------------------------------------\n");
|
||||||
}
|
}
|
||||||
@ -8,3 +8,12 @@ void test_autoarr(void);
|
|||||||
void test_searchtree(void);
|
void test_searchtree(void);
|
||||||
void test_all(void);
|
void test_all(void);
|
||||||
void test_autoarr2(void);
|
void test_autoarr2(void);
|
||||||
|
|
||||||
|
// executes codeblock and prints execution time
|
||||||
|
// should be used like optime({foo();}), because just optime(foo()) works slower
|
||||||
|
#define optime(codeblock) ({\
|
||||||
|
clock_t start=clock();\
|
||||||
|
(codeblock);\
|
||||||
|
clock_t stop=clock();\
|
||||||
|
printf("\e[96m%li\n",(stop-start));\
|
||||||
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user