void _profiler_mark_start(int type) { profiler_data *data = &global_profiler.data[global_profiler.dataindex]; osd_ticks_t curticks = get_profile_ticks(); profiler_filo_entry *entry; int index; /* track context switches */ if (type >= PROFILER_CPU_FIRST && type <= PROFILER_CPU_MAX) data->context_switches++; /* we're starting a new bucket, begin now */ index = global_profiler.filoindex++; entry = &global_profiler.filo[index]; /* fail if we overflow */ if (index > ARRAY_LENGTH(global_profiler.filo)) fatalerror("Profiler FILO overflow (type = %d)\n", type); /* if we're nested, stop the previous entry */ if (index > 0) { profiler_filo_entry *preventry = entry - 1; data->duration[preventry->type] += curticks - preventry->start; } /* fill in this entry */ entry->type = type; entry->start = curticks; }
void real_profiler_state::real_start(profile_type type) { osd_ticks_t curticks = get_profile_ticks(); // track context switches history_data &data = m_data[m_dataindex]; if (type >= PROFILER_DEVICE_FIRST && type <= PROFILER_DEVICE_MAX) data.context_switches++; // we're starting a new bucket, begin now int index = m_filoindex++; filo_entry &entry = m_filo[index]; // fail if we overflow if (index > ARRAY_LENGTH(m_filo)) throw emu_fatalerror("Profiler FILO overflow (type = %d)\n", type); // if we're nested, stop the previous entry if (index > 0) { filo_entry &preventry = m_filo[index - 1]; data.duration[preventry.type] += curticks - preventry.start; } // fill in this entry entry.type = type; entry.start = curticks; }
void poly_wait(poly_manager *poly, const char *debug_reason) { osd_ticks_t time; /* remember the start time if we're logging */ if (LOG_WAITS) time = get_profile_ticks(); /* wait for all pending work items to complete */ if (poly->queue != NULL) osd_work_queue_wait(poly->queue, osd_ticks_per_second() * 100); /* if we don't have a queue, just run the whole list now */ else { int unitnum; for (unitnum = 0; unitnum < poly->unit_next; unitnum++) poly_item_callback(poly->unit[unitnum], 0); } /* log any long waits */ if (LOG_WAITS) { time = get_profile_ticks() - time; if (time > LOG_WAIT_THRESHOLD) logerror("Poly:Waited %d cycles for %s\n", (int)time, debug_reason); } /* reset the state */ poly->polygon_next = poly->unit_next = 0; memset(poly->unit_bucket, 0xff, sizeof(poly->unit_bucket)); /* we need to preserve the last extra data that was supplied */ if (poly->extra_next > 1) memcpy(poly->extra[0], poly->extra[poly->extra_next - 1], poly->extra_size); poly->extra_next = 1; }
void _profiler_mark_end(void) { profiler_data *data = &global_profiler.data[global_profiler.dataindex]; osd_ticks_t curticks = get_profile_ticks(); /* we're ending an existing bucket, update the time */ if (global_profiler.filoindex > 0) { int index = --global_profiler.filoindex; profiler_filo_entry *entry = &global_profiler.filo[index]; /* account for the time taken */ data->duration[entry->type] += curticks - entry->start; /* if we have a previous entry, restart his time now */ if (index != 0) { profiler_filo_entry *preventry = entry - 1; preventry->start = curticks; } } }
void real_profiler_state::real_stop() { osd_ticks_t curticks = get_profile_ticks(); // we're ending an existing bucket, update the time if (m_filoindex > 0) { int index = --m_filoindex; filo_entry &entry = m_filo[index]; // account for the time taken history_data &data = m_data[m_dataindex]; data.duration[entry.type] += curticks - entry.start; // if we have a previous entry, restart his time now if (index != 0) { filo_entry &preventry = m_filo[index - 1]; preventry.start = curticks; } } }