MCPcopy Create free account
hub / github.com/corosync/corosync / cpg_benchmark

Function cpg_benchmark

test/cpgbenchzc.c:100–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98void *data;
99
100static 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) {
120retry:
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
145static void sigalrm_handler (int num)
146{

Callers 1

mainFunction · 0.70

Calls 3

cpg_zcb_mcast_joinedFunction · 0.85
cpg_dispatchFunction · 0.85

Tested by

no test coverage detected