X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/3e170ce000f1506b7b5d2c5c7faec85ceabb573d..b226f5e54a60dc81db17b1260381d7dbfea3cdf1:/tools/tests/MPMMTest/MPMMtest.c diff --git a/tools/tests/MPMMTest/MPMMtest.c b/tools/tests/MPMMTest/MPMMtest.c index c2991c37c..7dc344fd4 100644 --- a/tools/tests/MPMMTest/MPMMtest.c +++ b/tools/tests/MPMMTest/MPMMtest.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -17,6 +18,8 @@ #include #include #include +#include +#include "../unit_tests/tests_common.h" /* for record_perf_data() */ #include @@ -72,6 +75,7 @@ static boolean_t timeshare = FALSE; static boolean_t threaded = FALSE; static boolean_t oneway = FALSE; static boolean_t useset = FALSE; +static boolean_t save_perfdata = FALSE; int msg_type; int num_ints; int num_msgs; @@ -114,6 +118,7 @@ void usage(const char *progname) { fprintf(stderr, " -verbose\t\tbe verbose (use multiple times to increase verbosity)\n"); fprintf(stderr, " -oneway\t\tdo not request return reply\n"); fprintf(stderr, " -count num\t\tnumber of messages to send\n"); + fprintf(stderr, " -perf \t\tCreate perfdata files for metrics.\n"); fprintf(stderr, " -type trivial|inline|complex\ttype of messages to send\n"); fprintf(stderr, " -numints num\tnumber of 32-bit ints to send in messages\n"); fprintf(stderr, " -servers num\tnumber of server threads to run\n"); @@ -179,6 +184,9 @@ void parse_args(int argc, char *argv[]) { } else if (0 == strcmp("-oneway", argv[0])) { oneway = TRUE; argc--; argv++; + } else if (0 == strcmp("-perf", argv[0])) { + save_perfdata = TRUE; + argc--; argv++; } else if (0 == strcmp("-type", argv[0])) { if (argc < 2) usage(progname); @@ -940,6 +948,16 @@ int main(int argc, char *argv[]) printf(" average message latency (usec): %2.3g\n", dsecs * 1.0E6 / (double) totalmsg); + double time_in_sec = (double)deltatv.tv_sec + (double)deltatv.tv_usec/1000.0; + double throughput_msg_p_sec = (double) totalmsg/dsecs; + double avg_msg_latency = dsecs*1.0E6 / (double)totalmsg; + + if (save_perfdata == TRUE) { + char name[256]; + snprintf(name, sizeof(name), "%s_avg_msg_latency", basename(argv[0])); + record_perf_data(name, "usec", avg_msg_latency, "Message latency measured in microseconds. Lower is better", stderr); + } + if (stress_prepost) { int64_t sendns = abs_to_ns(g_client_send_time); dsecs = (double)sendns / (double)NSEC_PER_SEC;