#include <signal.h>
#include <bench-xseg.h>
+#include <math.h>
+
struct timespec delay = {0, 4000000};
/*
return num;
}
+/*
+ * Converts struct timespec to double (units in nanoseconds)
+ */
+static double timespec2double(struct timespec num)
+{
+ return (double) (num.tv_sec * pow(10, 9) + num.tv_nsec);
+}
+
int read_insanity(char *insanity)
{
if (strcmp(insanity, "sane") == 0)
return -1;
}
-void print_res(struct tm_result res, char *type)
+/*
+ * Seperates a double number in seconds, msec, usec, nsec
+ * Expects a number in nanoseconds (e.g. a number from timespec2double)
+ */
+static struct tm_result separate_by_order(double num)
+{
+ struct tm_result res;
+
+ //The format we expect is the following:
+ //
+ // |-s-|-ms-|-us-|-ns|
+ //num = 123 456 789 012 . 000000000000
+ res.s = num / pow(10,9);
+ num = fmod(num, pow(10,9));
+ res.ms = num / pow(10,6);
+ num = fmod(num, pow(10,6));
+ res.us = num / 1000;
+ res.ns = fmod(num, 1000);
+
+ return res;
+}
+
+void print_stats(struct bench *prefs)
{
+ uint64_t remaining;
+
printf("\n");
- printf(" %s\n", type);
- printf("================================\n");
- printf(" |-s-||-ms-|-us-|-ns-|\n");
- printf("Time: %3lu. %03lu %03lu %03lu\n",
- res.s, res.ms, res.us, res.ns);
+ printf("Requests total: %10lu\n", prefs->max_requests);
+ printf("Requests submitted: %10lu\n", prefs->sub_tm->completed);
+ printf("Requests received: %10lu\n", prefs->rec_tm->completed);
+ printf("\n");
+
+ remaining = prefs->max_requests - prefs->rec_tm->completed;
+ if (remaining)
+ printf("Requests remaining: %10lu\n", remaining);
+ else
+ printf("All requests have been served.\n");
}
-/*
- * Seperates a timespec struct in seconds, msec, usec, nsec
- */
-void separate_by_order(struct timespec src, struct tm_result *res)
+void print_res(struct bench *prefs, struct timer *tm, char *type)
{
- res->ns = src.tv_nsec % 1000;
- src.tv_nsec /= 1000;
- res->us = src.tv_nsec % 1000;
- res->ms = src.tv_nsec / 1000;
- res->s = src.tv_sec;
+ struct tm_result res;
+ double sum;
+
+ sum = timespec2double(tm->sum);
+ res = separate_by_order(sum);
+
+ printf("\n");
+ printf(" %s\n", type);
+ printf("=======================================\n");
+ printf(" |-s-||-ms-|-us-|-ns-|\n");
+ printf("Total time: %3u. %03u %03u %03u\n",
+ res.s, res.ms, res.us, res.ns);
+
+ res = separate_by_order(sum / prefs->rec_tm->completed);
+
+ printf("Mean Time: %3u. %03u %03u %03u\n",
+ res.s, res.ms, res.us, res.ns);
+
+ //TODO: Add std
}
void create_target(struct bench *prefs, struct xseg_request *req,
struct timespec sum;
struct timespec2 sum_sq;
struct timespec start_time;
- uint32_t completed;
- unsigned int insanity;
+ uint64_t completed;
+ int insanity;
};
struct tm_result {
- unsigned long s;
- unsigned long ms;
- unsigned long us;
- unsigned long ns;
+ unsigned int s;
+ unsigned int ms;
+ unsigned int us;
+ unsigned int ns;
};
/* FILLME
uint64_t str2num(char *str);
int read_op(char *op);
int read_pattern(char *pattern);
-void print_res(struct tm_result res, char *type);
-void separate_by_order(struct timespec src, struct tm_result *res);
+int read_insanity(char *insanity);
+void print_res(struct bench *prefs, struct timer *tm, char *type);
+void print_stats(struct bench *prefs);
void create_target(struct bench *prefs, struct xseg_request *req,
uint64_t new);
void create_chunk(struct bench *prefs, struct xseg_request *req,
uint64_t new);
uint64_t determine_next(struct bench *prefs);
void create_id();
-int read_insanity(char *insanity);
/**************\
* LFSR stuff *