Esempio n. 1
0
bool status_profile_rates(bool verbose)
{
	SMB_BIG_UINT remain_usec;
	SMB_BIG_UINT next_usec;
	SMB_BIG_UINT delta_usec;

	int last = 0;
	int current = 1;
	int tmp;

	if (verbose) {
	    fprintf(stderr, "Sampling stats at %d sec intervals\n",
		    usec_to_sec(sample_interval_usec));
	}

	if (!profile_setup(NULL, True)) {
		fprintf(stderr,"Failed to initialise profile memory\n");
		return False;
	}

	memcpy(&sample_data[last], profile_p, sizeof(*profile_p));
	for (;;) {
		sample_time[current] = profile_timestamp();
		next_usec = sample_time[current] + sample_interval_usec;

		/* Take a sample. */
		memcpy(&sample_data[current], profile_p, sizeof(*profile_p));

		/* Rate convert some values and print results. */
		delta_usec = sample_time[current] - sample_time[last];

		if (print_count_samples(&sample_data[current],
			&sample_data[last], delta_usec)) {
			printf("\n");
		}

		/* Swap sampling buffers. */
		tmp = last;
		last = current;
		current = tmp;

		/* Delay until next sample time. */
		remain_usec = next_usec - profile_timestamp();
		if (remain_usec > sample_interval_usec) {
			fprintf(stderr, "eek! falling behind sampling rate!\n");
		} else {
			if (verbose) {
			    fprintf(stderr,
				    "delaying for %lu msec\n",
				    (unsigned long )usec_to_msec(remain_usec));
			}

			sys_usleep(remain_usec);
		}

	}

	return True;
}
Esempio n. 2
0
ocrGuid_t endEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    ocrGuid_t infoGuid = depv[0].guid;
    info_t * info = (info_t *) depv[0].ptr;
    print_throughput("TEST", (info->max * NB_SATISFY), usec_to_sec(info->timer));
    ocrDbRelease(infoGuid);
    ocrDbDestroy(infoGuid);
    ocrShutdown();
    return NULL_GUID;
}
Esempio n. 3
0
static int print_count_samples(
	const struct profile_stats * const current,
	const struct profile_stats * const last,
	SMB_BIG_UINT delta_usec)
{
	int i;
	int count = 0;
	unsigned step;
	SMB_BIG_UINT spent;
	int delta_sec;
	const char * name;
	char buf[40];

	if (delta_usec == 0) {
		return 0;
	}

	buf[0] = '\0';
	delta_sec = usec_to_sec(delta_usec);

	for (i = 0; i < PR_VALUE_MAX; ++i) {
		step = current->count[i] - last->count[i];
		spent = current->time[i] - last->time[i];

		if (step) {
			++count;

			name = profile_value_name(i);

			if (buf[0] == '\0') {
				snprintf(buf, sizeof(buf),
					"%s %d/sec (%.2f%%)",
					name, step / delta_sec,
					percent_time(spent, delta_usec));
			} else {
				printf("%-40s %s %d/sec (%.2f%%)\n",
					buf, name, step / delta_sec,
					percent_time(spent, delta_usec));
				buf[0] = '\0';
			}
		}
	}

	return count;
}
Esempio n. 4
0
static double rate_convert_secs(unsigned count,
		const struct timeval *start, const struct timeval *end)
{
	return (double)count /
		usec_to_sec((double)usec_time_diff(end, start));
}
void
TrexStatelessDpCore::add_cont_stream(TrexStatelessDpPerPort * lp_port,
                                     TrexStream * stream,
                                     TrexStreamsCompiledObj *comp) {

    CGenNodeStateless *node = m_core->create_node_sl();

    /* add periodic */
    node->m_type = CGenNode::STATELESS_PKT;

    node->m_ref_stream_info  =   stream->clone_as_dp();

    node->m_next_stream=0; /* will be fixed later */


    if ( stream->m_self_start ){
        /* if self start it is in active mode */
        node->m_state =CGenNodeStateless::ss_ACTIVE;
        lp_port->m_active_streams++;
    }else{
        node->m_state =CGenNodeStateless::ss_INACTIVE;
    }

    node->m_time = m_core->m_cur_time_sec + usec_to_sec(stream->m_isg_usec);

    pkt_dir_t dir = m_core->m_node_gen.m_v_if->port_id_to_dir(stream->m_port_id);
    node->m_flags = 0; 

    /* set socket id */
    node->set_socket_id(m_core->m_node_gen.m_socket_id);

    /* build a mbuf from a packet */
    
    uint16_t pkt_size = stream->m_pkt.len;
    const uint8_t *stream_pkt = stream->m_pkt.binary;

    node->m_pause =0;
    node->m_stream_type = stream->m_type;
    node->m_next_time_offset =  1.0 / (stream->get_pps() * comp->get_multiplier()) ;


    /* stateless specific fields */
    switch ( stream->m_type ) {

    case TrexStream::stCONTINUOUS :
        node->m_single_burst=0;
        node->m_single_burst_refill=0;
        node->m_multi_bursts=0;
        node->m_ibg_sec                 = 0.0;
        break;

    case TrexStream::stSINGLE_BURST :
        node->m_stream_type             = TrexStream::stMULTI_BURST;
        node->m_single_burst            = stream->m_burst_total_pkts;
        node->m_single_burst_refill     = stream->m_burst_total_pkts;
        node->m_multi_bursts            = 1;  /* single burst in multi burst of 1 */
        node->m_ibg_sec                 = 0.0;
        break;

    case TrexStream::stMULTI_BURST :
        node->m_single_burst        = stream->m_burst_total_pkts;
        node->m_single_burst_refill = stream->m_burst_total_pkts;
        node->m_multi_bursts        = stream->m_num_bursts;
        node->m_ibg_sec             = usec_to_sec( stream->m_ibg_usec );
        break;
    default:

        assert(0);
    };

    node->m_port_id = stream->m_port_id;

    /* allocate const mbuf */
    rte_mbuf_t *m = CGlobalInfo::pktmbuf_alloc(node->get_socket_id(), pkt_size);
    assert(m);

    char *p = rte_pktmbuf_append(m, pkt_size);
    assert(p);
    /* copy the packet */
    memcpy(p,stream_pkt,pkt_size);

    /* set dir 0 or 1 client or server */
    node->set_mbuf_cache_dir(dir);

    /* TBD repace the mac if req we should add flag  */
    m_core->m_node_gen.m_v_if->update_mac_addr_from_global_cfg(dir, m);

    /* set the packet as a readonly */
    node->set_cache_mbuf(m);

    CDpOneStream one_stream;

    one_stream.m_dp_stream = node->m_ref_stream_info;
    one_stream.m_node =node;

    lp_port->m_active_nodes.push_back(one_stream);

    /* schedule only if active */
    if (node->m_state == CGenNodeStateless::ss_ACTIVE) {
        m_core->m_node_gen.add_node((CGenNode *)node);
    }
}
Esempio n. 6
0
void usec_to_tm(uint64_t usec, struct tm *result) {
  time_t sec = usec_to_sec(usec);
  gmtime_r(&sec, result);
}