simplified Autoarr/Hashtable _foreach

This commit is contained in:
2023-05-20 01:40:16 +06:00
parent d7136055d9
commit 461aef3a00
19 changed files with 78 additions and 71 deletions

View File

@@ -19,23 +19,23 @@
/// executes codeblock and prints execution time
/// u64 op_i is counter of the internal loop
/// uses non-standard high-precision clock
#define optime(opname,repeats,codeblock) ({ \
#define optime(opname, repeats, codeblock...) { \
struct timespec start, stop; \
clock_gettime(CLOCK_REALTIME, &start); \
for(u64 op_i=0;op_i<(u64)repeats;op_i++) \
(codeblock); \
{ codeblock; } \
clock_gettime(CLOCK_REALTIME, &stop); \
f64 t=(f64)(stop.tv_sec-start.tv_sec)*1000000+(f64)(stop.tv_nsec-start.tv_nsec)/1000; \
__optime_print(opname,t) \
})
__optime_print(opname,t); \
}
#else
/// uses standard low precision clock
#define optime(opname,repeats,codeblock) ({ \
#define optime(opname, repeats, codeblock...) { \
clock_t start=clock(); \
for(u64 op_i=0;op_i<(u64)repeats;op_i++) \
(codeblock); \
{ codeblock; } \
clock_t stop=clock(); \
f64 t=(f64)(stop-start)/CLOCKS_PER_SEC*1000000; \
__optime_print(opname,t) \
})
__optime_print(opname,t); \
}
#endif