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

Function cpg_benchmark

test/cpgbench.c:108–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106static char data[ONE_MEG];
107
108static void cpg_benchmark (
109 cpg_handle_t handle_in,
110 int write_size)
111{
112 struct timeval tv1, tv2, tv_elapsed;
113 struct iovec iov;
114 unsigned int res;
115
116 alarm_notice = 0;
117 iov.iov_base = data;
118 iov.iov_len = write_size;
119
120 write_count = 0;
121 alarm (10);
122
123 gettimeofday (&tv1, NULL);
124 do {
125 res = cpg_mcast_joined (handle_in, CPG_TYPE_AGREED, &iov, 1);
126 } while (alarm_notice == 0 && (res == CS_OK || res == CS_ERR_TRY_AGAIN));
127 gettimeofday (&tv2, NULL);
128 timersub (&tv2, &tv1, &tv_elapsed);
129
130 printf ("%5d messages received ", write_count);
131 printf ("%5d bytes per write ", write_size);
132 printf ("%7.3f Seconds runtime ",
133 (tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)));
134 printf ("%9.3f TP/s ",
135 ((float)write_count) / (tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)));
136 printf ("%7.3f MB/s.\n",
137 ((float)write_count) * ((float)write_size) / ((tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)) * 1000000.0));
138}
139
140static void sigalrm_handler (int num)
141{

Callers 1

mainFunction · 0.70

Calls 1

cpg_mcast_joinedFunction · 0.85

Tested by

no test coverage detected