X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6ee7e9c2e455536ab817ae0136acfbb53822eecd..307483ac1553316bf842eddd87031a3d6da30c2b:/src/instr/instr_paje_trace.c diff --git a/src/instr/instr_paje_trace.c b/src/instr/instr_paje_trace.c index 142b6183e3..cd144719bd 100644 --- a/src/instr/instr_paje_trace.c +++ b/src/instr/instr_paje_trace.c @@ -155,7 +155,7 @@ void TRACE_paje_start(void) { char *filename = TRACE_get_filename(); tracing_file = fopen(filename, "w"); - xbt_assert1 (tracing_file != NULL, "Tracefile %s could not be opened for writing.", filename); + xbt_assert (tracing_file != NULL, "Tracefile %s could not be opened for writing.", filename); XBT_DEBUG("Filename %s is open for writing", filename); @@ -331,37 +331,25 @@ void TRACE_paje_create_header(void) /* internal do the instrumentation module */ static void insert_into_buffer (paje_event_t tbi) { + if (TRACE_buffer() == 0){ + tbi->print (tbi); + tbi->free (tbi); + return; + } XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%ld)", __FUNCTION__, tbi->event_type, tbi->timestamp, xbt_dynar_length(buffer)); unsigned int i; - unsigned long len = xbt_dynar_length(buffer); - if (len == 0){ - xbt_dynar_push (buffer, &tbi); - XBT_DEBUG("%s: inserted at beginning", __FUNCTION__); - }else{ - //check if last event has the same timestamp that tbi event - paje_event_t e2 = *(paje_event_t*)xbt_dynar_get_ptr (buffer, len-1); - if (e2->timestamp == tbi->timestamp){ - //insert at the end - XBT_DEBUG("%s: inserted at end, pos = %ld", __FUNCTION__, len); - xbt_dynar_insert_at (buffer, len, &tbi); - return; - } - int inserted = 0; - for (i = 0; i < len; i++){ - paje_event_t e1 = *(paje_event_t*)xbt_dynar_get_ptr(buffer, i); - if (e1->timestamp > tbi->timestamp){ - xbt_dynar_insert_at (buffer, i, &tbi); - XBT_DEBUG("%s: inserted at %d", __FUNCTION__, i); - inserted = 1; - break; - } - } - if (!inserted){ - xbt_dynar_push (buffer, &tbi); - XBT_DEBUG("%s: inserted at end", __FUNCTION__); - } + for (i = xbt_dynar_length(buffer); i > 0; i--) { + paje_event_t e1 = *(paje_event_t*)xbt_dynar_get_ptr(buffer, i - 1); + if (e1->timestamp <= tbi->timestamp) + break; } + xbt_dynar_insert_at(buffer, i, &tbi); + if (i == 0) + XBT_DEBUG("%s: inserted at beginning", __FUNCTION__); + else + XBT_DEBUG("%s: inserted at%s %d", __FUNCTION__, + (i == xbt_dynar_length(buffer) - 1 ? " end, pos =" : ""), i); } static void print_pajeDefineContainerType(paje_event_t event)