Author: Tobias Weber <tobias_webe...@gmx.de> Branch: c8-overheads-instrumentation Changeset: r2029:4bb06ec721cd Date: 2017-03-13 12:29 +0100 http://bitbucket.org/pypy/stmgc/changeset/4bb06ec721cd/
Log: Add pause function to timing utility diff --git a/c8/stm/timing.h b/c8/stm/timing.h --- a/c8/stm/timing.h +++ b/c8/stm/timing.h @@ -1,19 +1,21 @@ #include <time.h> +#define continue_timer() clock_gettime(CLOCK_MONOTONIC_RAW, &start); + /* Use raw monotonic time, i.e., solely based on local hardware (no NTP adjustments) as in prof.c to obtain values comparable with total program runtime. */ -#define start_timer() struct timespec start; \ - clock_gettime(CLOCK_MONOTONIC_RAW, &start); +#define start_timer() struct timespec start, stop, duration = { 0, 0 }; \ + continue_timer() -#define stop_timer() struct timespec stop; \ - clock_gettime(CLOCK_MONOTONIC_RAW, &stop); +/* Must use start_timer before using this macro. */ +#define get_duration() duration.tv_sec = \ + stop.tv_sec - start.tv_sec + duration.tv_sec; \ + duration.tv_nsec = \ + stop.tv_nsec - start.tv_nsec + duration.tv_nsec; -/* Must use start_timer and stop_timer before using this macro. */ -#define get_duration() struct timespec duration = { \ - stop.tv_sec - start.tv_sec, \ - stop.tv_nsec - start.tv_nsec \ - }; +#define pause_timer() clock_gettime(CLOCK_MONOTONIC_RAW, &stop); \ + get_duration() #define stm_duration_payload(duration) \ stm_timing_event_payload_data_t stm_duration_data = \ @@ -23,10 +25,10 @@ #define publish_event(event) \ (timing_enabled() ? \ - stmcb_timing_event(STM_SEGMENT->running_thread, event, &stm_duration_payload) : \ + stmcb_timing_event( \ + STM_SEGMENT->running_thread, event, &stm_duration_payload) : \ (void)0); -#define stop_timer_and_publish(event) stop_timer() \ - get_duration() \ +#define stop_timer_and_publish(event) pause_timer() \ stm_duration_payload(duration) \ publish_event(event) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit