test: make fmt() function global
This commit is contained in:
parent
b779a0db74
commit
123ca8b87e
@ -43,35 +43,6 @@ struct async_req {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const char* fmt(double d) {
|
|
||||||
uint64_t v;
|
|
||||||
char* p;
|
|
||||||
|
|
||||||
p = (char *) calloc(1, 32) + 31; /* leaks memory */
|
|
||||||
v = d;
|
|
||||||
|
|
||||||
#if 0 /* works but we don't care about fractional precision */
|
|
||||||
if (d - v >= 0.01) {
|
|
||||||
*--p = '0' + (uint64_t) (d * 100) % 10;
|
|
||||||
*--p = '0' + (uint64_t) (d * 10) % 10;
|
|
||||||
*--p = '.';
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (v == 0)
|
|
||||||
*--p = '0';
|
|
||||||
|
|
||||||
while (v) {
|
|
||||||
if (v) *--p = '0' + (v % 10), v /= 10;
|
|
||||||
if (v) *--p = '0' + (v % 10), v /= 10;
|
|
||||||
if (v) *--p = '0' + (v % 10), v /= 10;
|
|
||||||
if (v) *--p = ',';
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void warmup(const char* path) {
|
static void warmup(const char* path) {
|
||||||
uv_fs_t reqs[MAX_CONCURRENT_REQS];
|
uv_fs_t reqs[MAX_CONCURRENT_REQS];
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@ -37,6 +37,35 @@ static void log_progress(int total, int passed, int failed, const char* name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* fmt(double d) {
|
||||||
|
uint64_t v;
|
||||||
|
char* p;
|
||||||
|
|
||||||
|
p = (char *) calloc(1, 32) + 31; /* leaks memory */
|
||||||
|
v = d;
|
||||||
|
|
||||||
|
#if 0 /* works but we don't care about fractional precision */
|
||||||
|
if (d - v >= 0.01) {
|
||||||
|
*--p = '0' + (uint64_t) (d * 100) % 10;
|
||||||
|
*--p = '0' + (uint64_t) (d * 10) % 10;
|
||||||
|
*--p = '.';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (v == 0)
|
||||||
|
*--p = '0';
|
||||||
|
|
||||||
|
while (v) {
|
||||||
|
if (v) *--p = '0' + (v % 10), v /= 10;
|
||||||
|
if (v) *--p = '0' + (v % 10), v /= 10;
|
||||||
|
if (v) *--p = '0' + (v % 10), v /= 10;
|
||||||
|
if (v) *--p = ',';
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int run_tests(int timeout, int benchmark_output) {
|
int run_tests(int timeout, int benchmark_output) {
|
||||||
int total, passed, failed;
|
int total, passed, failed;
|
||||||
task_entry_t* task;
|
task_entry_t* task;
|
||||||
|
|||||||
@ -106,4 +106,7 @@ typedef enum {
|
|||||||
/* Pause the calling thread for a number of milliseconds. */
|
/* Pause the calling thread for a number of milliseconds. */
|
||||||
void uv_sleep(int msec);
|
void uv_sleep(int msec);
|
||||||
|
|
||||||
|
/* Format big numbers nicely. WARNING: leaks memory. */
|
||||||
|
const char* fmt(double d);
|
||||||
|
|
||||||
#endif /* TASK_H_ */
|
#endif /* TASK_H_ */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user