Example #1
0
/**
* Run the simulation in shotmode.
*
* The simulation runs for #samples shots and takes stats for each one.
*/
void run_network_shotmode(void) {
	long iterations, i;

	reseted=-1;
	reset_stats();
	for (iterations=0; iterations<samples; iterations++) {
		printf("SHOT NUMBER %4ld started at time: %"PRINT_CLOCK"\n", iterations, sim_clock);
		printf("============================================\n");
		datagen_oneshot(TRUE);
		do {
			if ((sim_clock % update_period) == 0) {
				global_q_u = global_q_u_current;
				global_q_u_current = injected_count - rcvd_count - transit_dropped_count;
			}
			datagen_oneshot(FALSE);
			for (i=0; i<nprocs; i++) data_injection(i);
			data_movement(FALSE);
			sim_clock++;
			if ((pheaders > 0) && (sim_clock % pinterval == 0))
				print_partials();
		} while ((rcvd_count-last_rcvd_count) < total_shot_size);
		save_batch_results();
		print_batch_results(&batch[reseted]);
		reset_stats();
	}
}
Example #2
0
/* Renvoie 'a' le nombres de parties,
   'b' le nombre de victoires,
   'c' le nombre de victoires sans aide */
void read_stats (char data[3][6]) {
	FILE *f_stats = fopen("DATA", "r");
	if (f_stats == NULL) {
		strcpy(data[0], "0");
		strcpy(data[1], "0");
		strcpy(data[2], "0");
		reset_stats();
		return;
	}
	
	int i = 0;
	int l = 0;
	char c = (char)fgetc(f_stats);
	
	while (!feof(f_stats)) {
		if (l < 5 && strchr("0123456789", (int)c)) {
			data[i][l] = c;
			data[i][l+1] = '\0';
			l++;
		} else if (i < 2 && c == ' ') {
			i++;
			l = 0;
		} else if (!(i == 2 && c == '\n')) {
			fclose(f_stats);
			reset_stats();
			strcpy(data[0], "0");
			strcpy(data[1], "0");
			strcpy(data[2], "0");
			return;
		}
		
		c = (char)fgetc(f_stats);
	}
	fclose(f_stats);
}
Example #3
0
/**
* The simulation continues to assure convergency.
*
* Run the simulation and each #conv_period cycles estimates the convergency of the system.
* This phase ends when they are 3 converged samples in a row or when it spends more
* than #max_conv_time cycles without reach the stationary state. 
* A message stating the reason of leaving this phase is printed.
* 
* @see system_converges()
* @see run_network_batch()
*/
void convergency(void){
	long converged=FALSE;
	go_on=TRUE;
	while (go_on){
		data_movement(TRUE);
		sim_clock++;
		if ((pheaders > 0) && (sim_clock % pinterval == 0))
			print_partials();
		if (sim_clock % conv_period == 0 ){
			if ( system_converges() )
				convergence++;
			else
				convergence=0;

			if (convergence==3){
				go_on=FALSE;
				converged=TRUE;
			}
			prev_cons_load = cons_load;
			prev_latency = latency;
			reset_stats();
		}
		if (sim_clock % update_period == 0){
			global_q_u = global_q_u_current;
			global_q_u_current = injected_count - rcvd_count - transit_dropped_count;
		}
		if (sim_clock - warm_up_period >= max_conv_time)
			go_on=FALSE;
	}

	// Adjust for equal sample adquiring
	while (sim_clock % batch_time != 0){
		data_movement(TRUE);
		sim_clock++;
		if ((pheaders > 0) && (sim_clock % pinterval == 0))
			print_partials();

		if (sim_clock % update_period == 0){
			global_q_u = global_q_u_current;
			global_q_u_current = injected_count - rcvd_count - transit_dropped_count;
		}
	}
	warmed_up = sim_clock;
	reseted=-1;
	reset_stats();

	if (converged){
		printf("\n *********************************************\n");
		printf("*               Warmed Up !!!!!!              *\n");
		printf(" *********************************************\n\n");
	}
	else{
		printf("\n ********************************************\n");
		printf("*        Convergency timeout reached.        *\n");
		printf("*         Continue without converge!         *\n");
		printf(" ********************************************\n\n");
	}
}
static void basic_audio_stream() {
	AudioStream * 	marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE);
	stats_t marielle_stats;
	AudioStream * 	margaux = audio_stream_new (MARGAUX_RTP_PORT,MARGAUX_RTCP_PORT, FALSE);
	stats_t margaux_stats;
	RtpProfile* profile = rtp_profile_new("default profile");

	reset_stats(&marielle_stats);
	reset_stats(&margaux_stats);

	rtp_profile_set_payload (profile,0,&payload_type_pcmu8000);

	CU_ASSERT_EQUAL(audio_stream_start_full(margaux
											, profile
											, MARIELLE_IP
											, MARIELLE_RTP_PORT
											, MARIELLE_IP
											, MARIELLE_RTCP_PORT
											, 0
											, 50
											, NULL
											, RECORDED_8K_1S_FILE
											, NULL
											, NULL
											, 0),0);

	CU_ASSERT_EQUAL(audio_stream_start_full(marielle
											, profile
											, MARGAUX_IP
											, MARGAUX_RTP_PORT
											, MARGAUX_IP
											, MARGAUX_RTCP_PORT
											, 0
											, 50
											, HELLO_8K_1S_FILE
											, NULL
											, NULL
											, NULL
											, 0),0);

	ms_filter_add_notify_callback(marielle->soundread, notify_cb, &marielle_stats,TRUE);

	CU_ASSERT_TRUE(wait_for_until(&marielle->ms,&margaux->ms,&marielle_stats.number_of_EndOfFile,1,12000));

	audio_stream_get_local_rtp_stats(marielle,&marielle_stats.rtp);
	audio_stream_get_local_rtp_stats(margaux,&margaux_stats.rtp);

	/* No packet loss is assumed */
	CU_ASSERT_EQUAL(marielle_stats.rtp.sent,margaux_stats.rtp.recv);

	audio_stream_stop(marielle);
	audio_stream_stop(margaux);

	unlink(RECORDED_8K_1S_FILE);
}
Example #5
0
Cache::Cache(Storage* s)
{
  storage = s;
  reset_stats();
  blocksize = 1 << 10;  // 1KB
  memorysize = 1 << 20; // 1MB
}
Example #6
0
static void virtio_balloon_stat(void *opaque, MonitorCompletion cb,
                                void *cb_data)
{
    VirtIOBalloon *dev = opaque;

    /* For now, only allow one request at a time.  This restriction can be
     * removed later by queueing callback and data pairs.
     */
    if (dev->stats_callback != NULL) {
        return;
    }
    dev->stats_callback = cb;
    dev->stats_opaque_callback_data = cb_data;

    if (ENABLE_GUEST_STATS
        && (dev->vdev.guest_features & (1 << VIRTIO_BALLOON_F_STATS_VQ))) {
        virtqueue_push(dev->svq, &dev->stats_vq_elem, dev->stats_vq_offset);
        virtio_notify(&dev->vdev, dev->svq);
        return;
    }

    /* Stats are not supported.  Clear out any stale values that might
     * have been set by a more featureful guest kernel.
     */
    reset_stats(dev);
    complete_stats_request(dev);
}
Example #7
0
static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
{
    VirtIOBalloon *dev = opaque;

#if 0
    /* Disable guest-provided stats for now. For more details please check:
     * https://bugzilla.redhat.com/show_bug.cgi?id=623903
     *
     * If you do enable it (which is probably not going to happen as we
     * need a new command for it), remember that you also need to fill the
     * appropriate members of the BalloonInfo structure so that the stats
     * are returned to the client.
     */
    if (dev->vdev.guest_features & (1 << VIRTIO_BALLOON_F_STATS_VQ)) {
        virtqueue_push(dev->svq, &dev->stats_vq_elem, dev->stats_vq_offset);
        virtio_notify(&dev->vdev, dev->svq);
        return;
    }
#endif

    /* Stats are not supported.  Clear out any stale values that might
     * have been set by a more featureful guest kernel.
     */
    reset_stats(dev);

    info->actual = ram_size - ((uint64_t) dev->actual <<
                               VIRTIO_BALLOON_PFN_SHIFT);
}
Example #8
0
static void calc_average(PgStats *avg, PgStats *cur, PgStats *old)
{
	uint64_t query_count;
	uint64_t xact_count;

	usec_t dur = get_cached_time() - old_stamp;

	reset_stats(avg);

	if (dur <= 0)
		return;

	query_count = cur->query_count - old->query_count;
	xact_count = cur->xact_count - old->xact_count;

	avg->query_count = USEC * query_count / dur;
	avg->xact_count = USEC * xact_count / dur;

	avg->client_bytes = USEC * (cur->client_bytes - old->client_bytes) / dur;
	avg->server_bytes = USEC * (cur->server_bytes - old->server_bytes) / dur;

	if (query_count > 0)
		avg->query_time = (cur->query_time - old->query_time) / query_count;

	if (xact_count > 0)
		avg->xact_time = (cur->xact_time - old->xact_time) / xact_count;

	avg->wait_time = USEC * (cur->wait_time - old->wait_time) / dur;
}
Example #9
0
static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq)
{
    VirtIOBalloon *s = DO_UPCAST(VirtIOBalloon, vdev, vdev);
    VirtQueueElement *elem = &s->stats_vq_elem;
    VirtIOBalloonStat stat;
    size_t offset = 0;

    if (!virtqueue_pop(vq, elem)) {
        return;
    }

    /* Initialize the stats to get rid of any stale values.  This is only
     * needed to handle the case where a guest supports fewer stats than it
     * used to (ie. it has booted into an old kernel).
     */
    reset_stats(s);

    while (iov_to_buf(elem->out_sg, elem->out_num, &stat, offset, sizeof(stat))
           == sizeof(stat)) {
        uint16_t tag = tswap16(stat.tag);
        uint64_t val = tswap64(stat.val);

        offset += sizeof(stat);
        if (tag < VIRTIO_BALLOON_S_NR)
            s->stats[tag] = val;
    }
    s->stats_vq_offset = offset;

    complete_stats_request(s);
}
static int __init deepidle_init(void)
{
    int ret;

    pr_info("%s misc_register(%s)\n", __FUNCTION__, deepidle_device.name);

    ret = misc_register(&deepidle_device);

    if (ret) 
	{
	    pr_err("%s misc_register(%s) fail\n", __FUNCTION__, deepidle_device.name);

	    return 1;
	}

    if (sysfs_create_group(&deepidle_device.this_device->kobj, &deepidle_group) < 0) 
	{
	    pr_err("%s sysfs_create_group fail\n", __FUNCTION__);
	    pr_err("Failed to create sysfs group for device (%s)!\n", deepidle_device.name);
	}

    mutex_lock(&lock);
    reset_stats();
    mutex_unlock(&lock);

    return 0;
}
Example #11
0
VirtIODevice *virtio_balloon_init(DeviceState *dev)
{
    VirtIOBalloon *s;
    int ret;

    s = (VirtIOBalloon *)virtio_common_init("virtio-balloon",
                                            VIRTIO_ID_BALLOON,
                                            8, sizeof(VirtIOBalloon));

    s->vdev.get_config = virtio_balloon_get_config;
    s->vdev.set_config = virtio_balloon_set_config;
    s->vdev.get_features = virtio_balloon_get_features;

    ret = qemu_add_balloon_handler(virtio_balloon_to_target,
                                   virtio_balloon_stat, s);
    if (ret < 0) {
        virtio_cleanup(&s->vdev);
        return NULL;
    }

    s->ivq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
    s->dvq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
    s->svq = virtio_add_queue(&s->vdev, 128, virtio_balloon_receive_stats);

    reset_stats(s);

    s->qdev = dev;
    register_savevm(dev, "virtio-balloon", -1, 1,
                    virtio_balloon_save, virtio_balloon_load, s);

    return &s->vdev;
}
Example #12
0
static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
{
    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
    VirtIOBalloon *s = VIRTIO_BALLOON(dev);
    int ret;

    virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON,
                sizeof(struct virtio_balloon_config));

    ret = qemu_add_balloon_handler(virtio_balloon_to_target,
                                   virtio_balloon_stat, s);

    if (ret < 0) {
        error_setg(errp, "Only one balloon device is supported");
        virtio_cleanup(vdev);
        return;
    }

    s->ivq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
    s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
    s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);

    reset_stats(s);

    register_savevm(dev, "virtio-balloon", -1, 1,
                    virtio_balloon_save, virtio_balloon_load, s);

    object_property_add(OBJECT(dev), "guest-stats", "guest statistics",
                        balloon_stats_get_all, NULL, NULL, s, NULL);

    object_property_add(OBJECT(dev), "guest-stats-polling-interval", "int",
                        balloon_stats_get_poll_interval,
                        balloon_stats_set_poll_interval,
                        NULL, s, NULL);
}
Example #13
0
static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
{
    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
    VirtIOBalloon *s = VIRTIO_BALLOON(dev);
    int ret;

    virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON,
                sizeof(struct virtio_balloon_config));

    ret = qemu_add_balloon_handler(virtio_balloon_to_target,
                                   virtio_balloon_stat, s);

    if (ret < 0) {
        error_setg(errp, "Only one balloon device is supported");
        virtio_cleanup(vdev);
        return;
    }

    s->ivq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
    s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
    s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);

    reset_stats(s);

    register_savevm(dev, "virtio-balloon", -1, 1,
                    virtio_balloon_save, virtio_balloon_load, s);
}
Example #14
0
void tick_empty_users(gpointer key, User_stats * us, void *data) {
	if (is_new_tick(us->tick)) {
		us->tick = get_current_tick();
		Stats stats_holder;
		reset_stats(&stats_holder);
		push_stats(&stats_holder, us);
	}
}
Example #15
0
void mode_14_correct_answer() {
    play_feedback(MP3_CORRECT);
    speak_letters_in_word(mode_14_chosen_word);
    speak_word(mode_14_chosen_word);
    play_tada();
    score++;
    mode_14_play_stats();
    reset_globals();
    reset_stats();
}
Example #16
0
void Creature::process_turn()
{
    process_effects();

    // Call this in case any effects have changed our stats
    reset_stats();

    // add an appropriate number of moves
    moves += get_speed();
}
static void create_text_stream(text_stream_tester_t *tst, int payload_type) {
	tst->ts = text_stream_new2(tst->local_ip, tst->local_rtp, tst->local_rtcp);
	tst->local_rtp = rtp_session_get_local_port(tst->ts->ms.sessions.rtp_session);
	tst->local_rtcp = rtp_session_get_local_rtcp_port(tst->ts->ms.sessions.rtp_session);
	reset_stats(&tst->stats);
	rtp_session_set_multicast_loopback(tst->ts->ms.sessions.rtp_session, TRUE);
	tst->stats.q = ortp_ev_queue_new();
	rtp_session_register_event_queue(tst->ts->ms.sessions.rtp_session, tst->stats.q);
	tst->payload_type = payload_type;
}
Example #18
0
static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq)
{
    VirtIOBalloon *s = VIRTIO_BALLOON(vdev);
    VirtQueueElement *elem;
    VirtIOBalloonStat stat;
    size_t offset = 0;
    qemu_timeval tv;

    elem = virtqueue_pop(vq, sizeof(VirtQueueElement));
    if (!elem) {
        goto out;
    }

    if (s->stats_vq_elem != NULL) {
        /* This should never happen if the driver follows the spec. */
        virtqueue_push(vq, s->stats_vq_elem, 0);
        virtio_notify(vdev, vq);
        g_free(s->stats_vq_elem);
    }

    s->stats_vq_elem = elem;

    /* Initialize the stats to get rid of any stale values.  This is only
     * needed to handle the case where a guest supports fewer stats than it
     * used to (ie. it has booted into an old kernel).
     */
    reset_stats(s);

    while (iov_to_buf(elem->out_sg, elem->out_num, offset, &stat, sizeof(stat))
           == sizeof(stat)) {
        uint16_t tag = virtio_tswap16(vdev, stat.tag);
        uint64_t val = virtio_tswap64(vdev, stat.val);

        offset += sizeof(stat);
        if (tag < VIRTIO_BALLOON_S_NR)
            s->stats[tag] = val;
    }
    s->stats_vq_offset = offset;

    if (qemu_gettimeofday(&tv) < 0) {
        fprintf(stderr, "warning: %s: failed to get time of day\n", __func__);
        goto out;
    }

    s->stats_last_update = tv.tv_sec;

out:
    if (balloon_stats_enabled(s)) {
        balloon_stats_change_timer(s, s->stats_poll_interval);
    }
}
Example #19
0
/* under Linux a sighandler must reenable itself */
void sig_handler(int sig) {

    logmsg(LOG_INFO, "%s: signal %i received", STR_PROGNAME, sig);
    signal(sig, sig_handler);

    output_stats();
    reset_stats();

#ifdef DMALLOC
    logmsg(LOG_DEBUG, "%s: dumping dmalloc statistics", STR_PROGNAME);
    dmalloc_log_stats();
    dmalloc_log_unfreed();
#endif
}
Example #20
0
/* Custom handling of signals to handle stats */
static void
signal_handler(int signum) {
	switch(signum) {
	case SIGUSR1:
		MAIN_LOG("Received SIGUSR1. Printing statistics\n");
		print_stats();
		return;
	case SIGUSR2:
		MAIN_LOG("Received SIGUSR2. Resetting statistics\n");
		reset_stats();
		return;
	default:
		return;
	}
}
/* This function allows to reset the statistics of a specified process (identified by pid) */
int reset_values (int pid){
	  struct task_struct *t;

	  if (pid < 0)
	    return -EINVAL;

	  /* Searches for the process identified by pid */
	  t = find_task_by_pid (pid);
	  if (t < 0)
	    return -ESRCH;

	  /* Resets process stats */
	  reset_stats (pid, (struct my_thread *) t->thread_info);
	  return 0;
}
void Creature::process_turn()
{
    if(is_dead_state()) {
        return;
    }
    reset_bonuses();

    process_effects();

    // Call this in case any effects have changed our stats
    reset_stats();

    // add an appropriate number of moves
    moves += get_speed();
}
void report_idle_time(int idle_state, int idle_time)
{
    mutex_lock(&lock);

    num_idlecalls[idle_state]++;
    time_in_idlestate[idle_state] += (unsigned long long)idle_time;

    if (num_idlecalls[idle_state] == 0 || time_in_idlestate[idle_state] < (unsigned long long)idle_time)
	{
	    reset_stats();
	}

    mutex_unlock(&lock);

    return;
}
Example #24
0
static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
{
    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
    VirtIOBalloon *s = VIRTIO_BALLOON(dev);
    int ret;

    virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON,
                sizeof(struct virtio_balloon_config));

    ret = qemu_add_balloon_handler(virtio_balloon_to_target,
                                   virtio_balloon_stat, s);

    if (ret < 0) {
        error_setg(errp, "Only one balloon device is supported");
        virtio_cleanup(vdev);
        return;
    }

    s->ivq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
    s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
    s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);

    if (virtio_has_feature(s->host_features,
                           VIRTIO_BALLOON_F_FREE_PAGE_HINT)) {
        s->free_page_vq = virtio_add_queue(vdev, VIRTQUEUE_MAX_SIZE,
                                           virtio_balloon_handle_free_page_vq);
        s->free_page_report_status = FREE_PAGE_REPORT_S_STOP;
        s->free_page_report_cmd_id =
                           VIRTIO_BALLOON_FREE_PAGE_REPORT_CMD_ID_MIN;
        s->free_page_report_notify.notify =
                                       virtio_balloon_free_page_report_notify;
        precopy_add_notifier(&s->free_page_report_notify);
        if (s->iothread) {
            object_ref(OBJECT(s->iothread));
            s->free_page_bh = aio_bh_new(iothread_get_aio_context(s->iothread),
                                       virtio_ballloon_get_free_page_hints, s);
            qemu_mutex_init(&s->free_page_lock);
            qemu_cond_init(&s->free_page_cond);
            s->block_iothread = false;
        } else {
            /* Simply disable this feature if the iothread wasn't created. */
            s->host_features &= ~(1 << VIRTIO_BALLOON_F_FREE_PAGE_HINT);
            virtio_error(vdev, "iothread is missing");
        }
    }
    reset_stats(s);
}
Example #25
0
static void
test_reset_stats_succeeds_without_entries() {
  assert_true( init_stat() );

  reset_stats();

  hash_iterator iter;
  hash_entry *e = NULL;
  init_hash_iterator( stats, &iter );
  int n_entries = 0;
  while ( ( e = iterate_hash_next( &iter ) ) != NULL ) {
    n_entries++;
  }
  assert_int_equal( n_entries, 0 );

  assert_true( finalize_stat() );
}
Example #26
0
static int afpacket_daq_start(void *handle)
{
    AFPacket_Context_t *afpc = (AFPacket_Context_t *) handle;
    AFPacketInstance *instance;

    for (instance = afpc->instances; instance; instance = instance->next)
    {
        if (start_instance(afpc, instance) != 0)
            return DAQ_ERROR;
    }

    reset_stats(afpc);

    afpc->state = DAQ_STATE_STARTED;

    return DAQ_SUCCESS;
}
static void create_video_stream(video_stream_tester_t *vst, int payload_type) {
	vst->vs = video_stream_new2(vst->local_ip, vst->local_rtp, vst->local_rtcp);
	vst->vs->staticimage_webcam_fps_optimization = FALSE;
	vst->local_rtp = rtp_session_get_local_port(vst->vs->ms.sessions.rtp_session);
	vst->local_rtcp = rtp_session_get_local_rtcp_port(vst->vs->ms.sessions.rtp_session);
	reset_stats(&vst->stats);
	rtp_session_set_multicast_loopback(vst->vs->ms.sessions.rtp_session, TRUE);
	vst->stats.q = ortp_ev_queue_new();
	rtp_session_register_event_queue(vst->vs->ms.sessions.rtp_session, vst->stats.q);
	video_stream_set_event_callback(vst->vs, video_stream_event_cb, vst);
	if (vst->vconf) {
		PayloadType *pt = rtp_profile_get_payload(&rtp_profile, payload_type);
		CU_ASSERT_PTR_NOT_NULL_FATAL(pt);
		pt->normal_bitrate = vst->vconf->required_bitrate;
		video_stream_set_fps(vst->vs, vst->vconf->fps);
		video_stream_set_sent_video_size(vst->vs, vst->vconf->vsize);
	}
	vst->payload_type = payload_type;
}
Example #28
0
static void
test_reset_stats_succeeds_with_single_entry() {
  assert_true( init_stat() );

  const char *key = "key";
  increment_stat( key );

  reset_stats();

  hash_iterator iter;
  hash_entry *e = NULL;
  init_hash_iterator( stats, &iter );
  int n_entries = 0;
  while ( ( e = iterate_hash_next( &iter ) ) != NULL ) {
    n_entries++;
  }
  assert_int_equal( n_entries, 0 );

  assert_true( finalize_stat() );
}
Example #29
0
bool admin_database_stats(PgSocket *client, struct StatList *pool_list)
{
	PgPool *pool;
	struct List *item;
	PgDatabase *cur_db = NULL;
	PgStats st_total, st_db, old_db, old_total;
	int rows = 0;
	PktBuf *buf;

	reset_stats(&st_total);
	reset_stats(&st_db);
	reset_stats(&old_db);
	reset_stats(&old_total);

	buf = pktbuf_dynamic(512);
	if (!buf) {
		admin_error(client, "no mem");
		return true;
	}

	pktbuf_write_RowDescription(buf, "sqqqqqqqqqqqqqq", "database",
				    "total_xact_count", "total_query_count",
				    "total_received", "total_sent",
				    "total_xact_time", "total_query_time",
				    "total_wait_time",
				    "avg_xact_count", "avg_query_count",
				    "avg_recv", "avg_sent",
				    "avg_xact_time", "avg_query_time",
				    "avg_wait_time");
	statlist_for_each(item, pool_list) {
		pool = container_of(item, PgPool, head);

		if (!cur_db)
			cur_db = pool->db;

		if (pool->db != cur_db) {
			write_stats(buf, &st_db, &old_db, cur_db->name);

			rows ++;
			cur_db = pool->db;
			stat_add(&st_total, &st_db);
			stat_add(&old_total, &old_db);
			reset_stats(&st_db);
			reset_stats(&old_db);
		}

		stat_add(&st_db, &pool->stats);
		stat_add(&old_db, &pool->older_stats);
	}
Example #30
0
int query1() {
    int maxano, minano, npublics, nomes;

    char filename[40];
    char *linha;
    maxano = minano = npublics = nomes = 0;
    printf("Ficheiro para leitura: ");
    if (fgets(filename, 40, stdin) != NULL) {
        linha = newline(filename);
        reset_index();
        reset_stats();
        reset_lista();
        reset_length();
        reset_catalogo();
        if (parser_file(linha) == 0) {
            printf("Erro na abertura do ficheiro(Talvez ficheiro não exista ou tenha outro nome?)\n");
        } else {

            maxano = getMaxAno();
            minano = getMinAno();
            npublics = getNPublics();
            nomes = getNomes();
            printf("Ficheiro lido: %s\n", linha);
            printf("Nº publicacoes: %d\n", npublics);
            printf("Anos: [%d a %d]\n", minano, maxano);

            printf("Nº de nomes lidos: %d\n", nomes);


        }
    } else {
        printf("Erro na abertura do ficheiro");
    }


    return 1;
}