FreeBSD/usr.sbin/pmcannotate/pmcannotate.c
/*
 * Insert a raw entry into the aggregations queue.
 * If the respective first-level aggregation object
 * does not exist create it and maintain it sorted
 * in respect of the number of samples.
 */
Insert a raw entry into the aggregations queue.
If the respective first-level aggregation object
does not exist create it and maintain it sorted
in respect of the number of samples.
Insert a raw entry into the aggregations queue . If the respective first - level aggregation object does not exist create it and maintain it sorted in respect of the number of samples .
static int
fqueue_insertent(struct entry *entry)
{
	struct aggent *obj, *tmp;
	int found;
	found = 0;
	TAILQ_FOREACH(obj, &fqueue, ag_fiter)
		if (!strcmp(obj->ag_name, entry->en_name)) {
			found = 1;
			obj->ag_nsamples += entry->en_nsamples;
			break;
		}
	if (found) {
		TAILQ_REMOVE(&fqueue, obj, ag_fiter);
		found = 0;
		TAILQ_FOREACH(tmp, &fqueue, ag_fiter)
			if (obj->ag_nsamples > tmp->ag_nsamples) {
				found = 1;
				break;
			}
		if (found)
			TAILQ_INSERT_BEFORE(tmp, obj, ag_fiter);
		else
			TAILQ_INSERT_TAIL(&fqueue, obj, ag_fiter);
		return (0);
	}
	obj = agg_create(entry->en_name, entry->en_nsamples, entry->en_ostart,
	    entry->en_oend);
	if (obj == NULL)
		return (-1);
	if (TAILQ_EMPTY(&fqueue) != 0) {
		TAILQ_INSERT_HEAD(&fqueue, obj, ag_fiter);
		return (0);
	}
	TAILQ_FOREACH(tmp, &fqueue, ag_fiter)
		if (obj->ag_nsamples > tmp->ag_nsamples) {
			found = 1;
			break;
		}
	if (found)
		TAILQ_INSERT_BEFORE(tmp, obj, ag_fiter);
	else
		TAILQ_INSERT_TAIL(&fqueue, obj, ag_fiter);
	return (0);
}
static int fqueue_insertent ( struct entry * entry ) { struct aggent * obj , * tmp ; int found ; found = 0 ; TAILQ_FOREACH ( obj , & fqueue , ag_fiter ) if ( ! strcmp ( obj -> ag_name , entry -> en_name ) ) { found = 1 ; obj -> ag_nsamples += entry -> en_nsamples ; break ; } if ( found ) { TAILQ_REMOVE ( & fqueue , obj , ag_fiter ) ; found = 0 ; TAILQ_FOREACH ( tmp , & fqueue , ag_fiter ) if ( obj -> ag_nsamples > tmp -> ag_nsamples ) { found = 1 ; break ; } if ( found ) TAILQ_INSERT_BEFORE ( tmp , obj , ag_fiter ) ; else TAILQ_INSERT_TAIL ( & fqueue , obj , ag_fiter ) ; return ( 0 ) ; } obj = agg_create ( entry -> en_name , entry -> en_nsamples , entry -> en_ostart , entry -> en_oend ) ; if ( obj == NULL ) return ( -1 ) ; if ( TAILQ_EMPTY ( & fqueue ) != 0 ) { TAILQ_INSERT_HEAD ( & fqueue , obj , ag_fiter ) ; return ( 0 ) ; } TAILQ_FOREACH ( tmp , & fqueue , ag_fiter ) if ( obj -> ag_nsamples > tmp -> ag_nsamples ) { found = 1 ; break ; } if ( found ) TAILQ_INSERT_BEFORE ( tmp , obj , ag_fiter ) ; else TAILQ_INSERT_TAIL ( & fqueue , obj , ag_fiter ) ; return ( 0 ) ; }
Insert a raw entry into the aggregations queue.
Insert a raw entry into the aggregations queue .
/*
	 * If the first-level aggregation object already exists,
	 * just aggregate the samples and, if needed, resort
	 * it.
	 */ /*
	 * If the first-level aggregation object does not
	 * exist, create it and put in the sorted queue.
	 * If this is the first object, we need to set the
	 * head of the queue.
	 */