bmc.c | bmc.c | |||
---|---|---|---|---|
skipping to change at line 35 | skipping to change at line 35 | |||
#include <qb/qbutil.h> | #include <qb/qbutil.h> | |||
#include <qb/qbipcc.h> | #include <qb/qbipcc.h> | |||
#define ITERATIONS 10000 | #define ITERATIONS 10000 | |||
pid_t mypid; | pid_t mypid; | |||
int32_t blocking = QB_TRUE; | int32_t blocking = QB_TRUE; | |||
int32_t events = QB_FALSE; | int32_t events = QB_FALSE; | |||
int32_t verbose = 0; | int32_t verbose = 0; | |||
static qb_ipcc_connection_t *conn; | static qb_ipcc_connection_t *conn; | |||
#define MAX_MSG_SIZE (8192*128) | #define MAX_MSG_SIZE (8192*128) | |||
static qb_util_stopwatch_t *sw; | ||||
static struct timeval tv1, tv2, tv_elapsed; | ||||
#ifndef QB_BSD | ||||
#define timersub(a, b, result) \ | ||||
do { \ | ||||
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ | ||||
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ | ||||
if ((result)->tv_usec < 0) { \ | ||||
--(result)->tv_sec; \ | ||||
(result)->tv_usec += 1000000; \ | ||||
} \ | ||||
} while (0) | ||||
#endif | ||||
static void bm_start(void) | ||||
{ | ||||
gettimeofday(&tv1, NULL); | ||||
} | ||||
static void bm_finish(const char *operation, int32_t size) | static void bm_finish(const char *operation, int32_t size) | |||
{ | { | |||
float ops_per_sec; | float ops_per_sec; | |||
float mbs_per_sec; | float mbs_per_sec; | |||
float elapsed; | ||||
gettimeofday(&tv2, NULL); | qb_util_stopwatch_stop(sw); | |||
timersub(&tv2, &tv1, &tv_elapsed); | elapsed = qb_util_stopwatch_sec_elapsed_get(sw); | |||
ops_per_sec = ((float)ITERATIONS) / elapsed; | ||||
ops_per_sec = | mbs_per_sec = ((((float)ITERATIONS) * size) / elapsed) / (1024.0 * 1 | |||
((float)ITERATIONS) / (((float)tv_elapsed.tv_sec) + | 024.0); | |||
(((float)tv_elapsed.tv_usec) / 1000000.0) | ||||
); | ||||
mbs_per_sec = | ||||
((((float)ITERATIONS) * size) / | ||||
(((float)tv_elapsed.tv_sec) + | ||||
(((float)tv_elapsed.tv_usec) / 1000000.0))) / (1024.0 * 1024.0 | ||||
); | ||||
printf("write size, %d, OPs/sec, %9.3f, ", size, ops_per_sec); | printf("write size, %d, OPs/sec, %9.3f, ", size, ops_per_sec); | |||
printf("MB/sec, %9.3f\n", mbs_per_sec); | printf("MB/sec, %9.3f\n", mbs_per_sec); | |||
} | } | |||
static char buffer[1024 * 1024]; | struct my_req { | |||
struct qb_ipc_request_header hdr; | ||||
char message[1024 * 1024]; | ||||
}; | ||||
static struct my_req request; | ||||
static int32_t bmc_send_nozc(uint32_t size) | static int32_t bmc_send_nozc(uint32_t size) | |||
{ | { | |||
struct qb_ipc_request_header *req_header = (struct qb_ipc_request_he ader *)buffer; | ||||
struct qb_ipc_response_header res_header; | struct qb_ipc_response_header res_header; | |||
int32_t res; | int32_t res; | |||
req_header->id = QB_IPC_MSG_USER_START + 3; | request.hdr.id = QB_IPC_MSG_USER_START + 3; | |||
req_header->size = sizeof(struct qb_ipc_request_header) + size; | request.hdr.size = sizeof(struct qb_ipc_request_header) + size; | |||
repeat_send: | repeat_send: | |||
res = qb_ipcc_send(conn, req_header, req_header->size); | res = qb_ipcc_send(conn, &request, request.hdr.size); | |||
if (res < 0) { | if (res < 0) { | |||
if (res == -EAGAIN) { | if (res == -EAGAIN) { | |||
goto repeat_send; | goto repeat_send; | |||
} else if (res == -EINVAL || res == -EINTR || res == -ENOTCO NN) { | } else if (res == -EINVAL || res == -EINTR || res == -ENOTCO NN) { | |||
perror("qb_ipcc_send"); | perror("qb_ipcc_send"); | |||
return -1; | return -1; | |||
} else { | } else { | |||
errno = -res; | errno = -res; | |||
perror("qb_ipcc_send"); | perror("qb_ipcc_send"); | |||
goto repeat_send; | goto repeat_send; | |||
skipping to change at line 201 | skipping to change at line 182 | |||
signal(SIGINT, sigterm_handler); | signal(SIGINT, sigterm_handler); | |||
signal(SIGILL, sigterm_handler); | signal(SIGILL, sigterm_handler); | |||
signal(SIGTERM, sigterm_handler); | signal(SIGTERM, sigterm_handler); | |||
conn = qb_ipcc_connect("bm1", MAX_MSG_SIZE); | conn = qb_ipcc_connect("bm1", MAX_MSG_SIZE); | |||
if (conn == NULL) { | if (conn == NULL) { | |||
perror("qb_ipcc_connect"); | perror("qb_ipcc_connect"); | |||
exit(1); | exit(1); | |||
} | } | |||
sw = qb_util_stopwatch_create(); | ||||
size = QB_MAX(sizeof(struct qb_ipc_request_header), 64); | size = QB_MAX(sizeof(struct qb_ipc_request_header), 64); | |||
for (j = 0; j < 20; j++) { | for (j = 0; j < 20; j++) { | |||
if (size >= MAX_MSG_SIZE) | if (size >= MAX_MSG_SIZE) | |||
break; | break; | |||
bm_start(); | qb_util_stopwatch_start(sw); | |||
for (i = 0; i < ITERATIONS; i++) { | for (i = 0; i < ITERATIONS; i++) { | |||
if (bmc_send_nozc(size) == -1) { | if (bmc_send_nozc(size) == -1) { | |||
break; | break; | |||
} | } | |||
} | } | |||
bm_finish("send_nozc", size); | bm_finish("send_nozc", size); | |||
size *= 2; | size *= 2; | |||
} | } | |||
qb_ipcc_disconnect(conn); | qb_ipcc_disconnect(conn); | |||
End of changes. 9 change blocks. | ||||
38 lines changed or deleted | 19 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |