Ejemplo n.º 1
0
/*---------------------------------------------------------------------------*/
void
timetable_aggregate_compute_categories(struct timetable_aggregate *a,
				       struct timetable *timetable)
{
  int i,j;
  rtimer_clock_t t;
  uint16_t categories[XXX_HACK_MAX_CATEGORIES];
  int categories_ptr = 0;

  t = timetable->timestamps[0].time;

  for(i = 1; i < *timetable->ptr; ++i) {
    struct timetable_aggregate_entry *entry;
    uint16_t cat;

    /*    printf("category_timetable_aggregate_compute %s %d\n",
	  timetable->timestamps[i - 1].id, i);*/
    cat = (timetable->timestamps[i - 1].id[0] << 8) +
      (timetable->timestamps[i - 1].id[1] & 0xff);
    entry = find_aggregate_category(a, cat);
    if(entry == NULL) {
      /* The list is full, skip this entry */
      /*      printf("category_timetable_aggregate_compute: list full\n");*/
    } else if(entry->id == NULL) {
      /* The category was not found in the list, so we add it. */
      entry->id = timetable->timestamps[i - 1].id;
      entry->time = (unsigned long)(timetable->timestamps[i].time - t -
				    timetable_timestamp_time);
      entry->episodes = 1;
      /*      printf("New category %c%c time %lu\n",
	     timetable->timestamps[i - 1].id[0],
	     timetable->timestamps[i - 1].id[1], entry->time);*/
    } else {

      entry->time += (unsigned long)(timetable->timestamps[i].time - t -
				     timetable_timestamp_time);
      /*      printf("Adding time to %c%c time %lu\n",
	     timetable->timestamps[i - 1].id[0],
	     timetable->timestamps[i - 1].id[1], entry->time);*/

      /* Make sure that we only update the episodes of each category
	 once per run. We keep track of all updated categories in the
	 "categories" array. If the category is already present in the
	 array, we do not update it. Otherwise, we insert the category
	 in the array and update the episodes counter of the
	 category. */

      for(j = 0; j < categories_ptr; ++j) {
	if(categories[j] == cat) {
	  break;
	}
      }
      if(j == categories_ptr) {
	categories[j] = cat;
	categories_ptr++;
	entry->episodes++;
      }
    }
    t = timetable->timestamps[i].time;
  }
}
Ejemplo n.º 2
0
/*---------------------------------------------------------------------------*/
static void
category_profile_aggregates_compute(void)
{
    int i,j;
    rtimer_clock_t t;
    uint16_t categories[MAX_CATEGORIES];
    int categories_ptr = 0;
    /*  const char *str = "profile_aggregates_compute";

    PROFILE_TIMESTAMP(str);*/

    t = profile_timestamps[0].time;

    for(i = 1; i < PROFILE_TIMESTAMP_PTR; ++i) {
        struct aggregate *a;
        uint16_t cat;

        /*     printf("category_profile_aggregates_compute %s\n", */
        /* 	   profile_timestamps[i - 1].ptr); */
        cat = (profile_timestamps[i - 1].ptr[0] << 8) +
              (profile_timestamps[i - 1].ptr[1] & 0xff);
        a = find_aggregate_category(cat);
        if(a == NULL) {
            /* The list is full, skip this entry */
            printf("profile_aggregates_compute: list full\n");
        } else if(a->ptr == NULL) {
            a->ptr = profile_timestamps[i - 1].ptr;
            a->cycles = (unsigned long)(profile_timestamps[i].time - t - profile_timestamp_time);
            a->episodes = 1;
        } else {

            a->cycles += (unsigned long)(profile_timestamps[i].time - t - profile_timestamp_time);

            /* Make sure that we only update the episodes of each category
            once per run. We keep track of all updated categories in the
             "categories" array. If the category is already present in the
             array, we do not update it. Otherwise, we insert the category
             in the array and update the episodes counter of the
             category. */

            for(j = 0; j < categories_ptr; ++j) {
                if(categories[j] == cat) {
                    break;
                }
            }
            if(j == categories_ptr) {
                categories[j] = cat;
                categories_ptr++;
                a->episodes++;
            }
        }
        t = profile_timestamps[i].time;
    }

    /*  PROFILE_TIMESTAMP(str);*/

    /*printf("Aggregating time %u, len %d, list len %d, overhead %d\n",
     profile_timediff(str, str), PROFILE_TIMESTAMP_PTR,
     aggregates_list_ptr, profile_timestamp_time);*/


    /* print_aggregates();*/
}