cosmopolitan/third_party/mbedtls/profile.h
Justine Tunney ead3fc2b31 Fix Landlock Make so it can read pattern rule vars
It turned out that specifying all SRCS and INCS as dependencies on the
pattern rules for all headers, caused `make` memory usage to skyrocket
from 40mb ot 160mb. This change also reduces the build graph another 4%.
2022-08-13 17:23:05 -07:00

43 lines
1 KiB
C

#ifndef COSMOPOLITAN_THIRD_PARTY_MBEDTLS_PROFILE_H_
#define COSMOPOLITAN_THIRD_PARTY_MBEDTLS_PROFILE_H_
#include "libc/intrin/safemacros.internal.h"
#include "libc/log/log.h"
#include "libc/nexgen32e/bench.h"
#include "libc/nexgen32e/rdtsc.h"
#if 1
#define START() \
{ \
volatile uint64_t Time = __startbench()
#define STOP(x) \
fprintf(stderr, "PROFILE %,10ldc %s\n", \
unsignedsubtract(__endbench(), Time), #x); \
}
#define PROFILE(x) \
({ \
typeof(x) Res; \
START(); \
Res = (x); \
STOP(x); \
Res; \
})
#define PROFILS(x) \
do { \
START(); \
x; \
STOP(x); \
} while (0)
#define PRINT() \
fprintf(stderr, "PRINT %s called by %s\n", __FUNCTION__, GetCallerName(0))
#else
#define PRINT() ((void)0)
#define PROFILE(x) x
#define PROFILS(x) x
#define START() ((void)0)
#define STOP(x) ((void)0)
#endif
#endif /* COSMOPOLITAN_THIRD_PARTY_MBEDTLS_PROFILE_H_ */