void wait_all_plugin_to_finish(GPtrArray *plugin_array) { if (!plugin_array) return; struct timeval start_time; gettimeofday(&start_time, NULL); for (int i=0; i < plugin_array->len; i++) { PluginInfo *plugin = g_ptr_array_index(plugin_array,i); if (!plugin) continue; while (plugin->get_thread_count() > 0) { g_usleep(500*1000); print_statistic(&start_time); } } /* print final statistic: */ print_statistic(&start_time); unsigned long count = sent_messages_num; struct timeval now; gettimeofday(&now, NULL); double total_runtime_sec = time_val_diff_in_sec(&now, &start_time); if (total_runtime_sec > 0 && count > 0) fprintf(stderr, "average rate = %.2lf msg/sec, count=%ld, time=%g, (average) msg size=%"G_GINT64_FORMAT", bandwidth=%.2f kB/sec\n", (double)count/total_runtime_sec, count, total_runtime_sec, (gint64)raw_message_length/count, (double)raw_message_length/(total_runtime_sec*1024) ); else fprintf(stderr, "Total runtime = %g, count = %ld\n",total_runtime_sec, count); }