| 98 | void *data; |
| 99 | |
| 100 | static void cpg_benchmark ( |
| 101 | cpg_handle_t handle, |
| 102 | int write_size) |
| 103 | { |
| 104 | struct timeval tv1, tv2, tv_elapsed; |
| 105 | unsigned int res; |
| 106 | cpg_flow_control_state_t flow_control_state; |
| 107 | |
| 108 | alarm_notice = 0; |
| 109 | |
| 110 | write_count = 0; |
| 111 | alarm (10); |
| 112 | |
| 113 | gettimeofday (&tv1, NULL); |
| 114 | do { |
| 115 | /* |
| 116 | * Test checkpoint write |
| 117 | */ |
| 118 | cpg_flow_control_state_get (handle, &flow_control_state); |
| 119 | if (flow_control_state == CPG_FLOW_CONTROL_DISABLED) { |
| 120 | retry: |
| 121 | res = cpg_zcb_mcast_joined (handle, CPG_TYPE_AGREED, data, write_size); |
| 122 | if (res == CS_ERR_TRY_AGAIN) { |
| 123 | goto retry; |
| 124 | } |
| 125 | } |
| 126 | res = cpg_dispatch (handle, CS_DISPATCH_ALL); |
| 127 | if (res != CS_OK) { |
| 128 | printf ("cpg dispatch returned error %d\n", res); |
| 129 | exit (1); |
| 130 | } |
| 131 | } while (alarm_notice == 0); |
| 132 | gettimeofday (&tv2, NULL); |
| 133 | timersub (&tv2, &tv1, &tv_elapsed); |
| 134 | |
| 135 | printf ("%5d messages received ", write_count); |
| 136 | printf ("%5d bytes per write ", write_size); |
| 137 | printf ("%7.3f Seconds runtime ", |
| 138 | (tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0))); |
| 139 | printf ("%9.3f TP/s ", |
| 140 | ((float)write_count) / (tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0))); |
| 141 | printf ("%7.3f MB/s.\n", |
| 142 | ((float)write_count) * ((float)write_size) / ((tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)) * 1000000.0)); |
| 143 | } |
| 144 | |
| 145 | static void sigalrm_handler (int num) |
| 146 | { |
no test coverage detected