Permalink
Browse files

test: make fmt() function global

  • Loading branch information...
1 parent b779a0d commit 123ca8b87e73ad7f613e44f0d4fac65c7468862e @bnoordhuis bnoordhuis committed Jun 28, 2012
Showing with 32 additions and 29 deletions.
  1. +0 −29 test/benchmark-fs-stat.c
  2. +29 −0 test/runner.c
  3. +3 −0 test/task.h
@@ -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) {
uv_fs_t reqs[MAX_CONCURRENT_REQS];
int i;
View
@@ -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 total, passed, failed;
task_entry_t* task;
View
@@ -106,4 +106,7 @@ typedef enum {
/* Pause the calling thread for a number of milliseconds. */
void uv_sleep(int msec);
+/* Format big numbers nicely. WARNING: leaks memory. */
+const char* fmt(double d);
+
#endif /* TASK_H_ */

0 comments on commit 123ca8b

Please sign in to comment.