Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:16.0:Staging:adi:44
latrace
0002-stats-bugfix-use-timersub-and-timeradd.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0002-stats-bugfix-use-timersub-and-timeradd.patch of Package latrace
From 749d16e7ac7dab3641d23eeead752335e23854f4 Mon Sep 17 00:00:00 2001 From: Akos PASZTORY <akos.pasztory@gmail.com> Date: Sat, 3 Dec 2011 15:42:56 +0000 Subject: [PATCH 2/4] stats: bugfix: use timersub() and timeradd() tv_sub() had a bug: if 'a' represented the same time as 'b' then it added extra 1000000 usecs. --- ChangeLog | 4 ++++ src/stats.c | 41 +++++------------------------------------ 2 files changed, 9 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65dff9b..9afa02c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-12-05 Jiri Olsa <olsajiri@gmail.com> + * stats bugfix - use timersub() and timeradd() + (contributed by Akos Pasztory <akos.pasztory@gmail.com>) + 2011-09-05 Jiri Olsa <olsajiri@gmail.com> * Fixes paraller building like 'make -j16' (contributed by Tapani Pälli <tapani.palli@intel.com>) diff --git a/src/stats.c b/src/stats.c index b1c8dda..d5c5351 100644 --- a/src/stats.c +++ b/src/stats.c @@ -31,37 +31,6 @@ struct timeval tv_program_start; struct timeval tv_program_stop; -/* res = a - b*/ -static int tv_sub(struct timeval *res, struct timeval *a, struct timeval *b) -{ - res->tv_sec = a->tv_sec - b->tv_sec; - - if (a->tv_usec > b->tv_usec) - res->tv_usec = a->tv_usec - b->tv_usec; - else { - res->tv_usec = a->tv_usec + (1000000 - b->tv_usec); - if (res->tv_sec) - res->tv_sec--; - } - - return 0; -} - -/* res = a + b*/ -static int tv_add(struct timeval *res, struct timeval *a, struct timeval *b) -{ - struct timeval tv; - tv.tv_sec = a->tv_sec + b->tv_sec; - tv.tv_usec = a->tv_usec + b->tv_usec; - if (tv.tv_usec > 1000000) { - tv.tv_usec -= 1000000; - tv.tv_sec++; - } - - *res = tv; - return 0; -} - int lt_stats_alloc(struct lt_config_app *cfg, struct lt_thread *t) { int i; @@ -186,8 +155,8 @@ int lt_stats_sym(struct lt_config_app *cfg, struct lt_thread *t, if (FIFO_MSG_TYPE_EXIT == m->h.type) { struct timeval tv; - tv_sub(&tv, &m->h.tv, &sym->tv_cur); - tv_add(&sym->tv_all, &sym->tv_all, &tv); + timersub(&m->h.tv, &sym->tv_cur, &tv); + timeradd(&sym->tv_all, &tv, &sym->tv_all); } return 0; @@ -248,7 +217,7 @@ static int lt_stats_show_thread(struct lt_config_app *cfg, struct lt_thread *t) for(i = 0; i < t->sym_cnt; i++) { struct lt_stats_sym *sym = t->sym_array[i]; - tv_add(&tv_thread_accu, &tv_thread_accu, &sym->tv_all); + timeradd(&sym->tv_all, &tv_thread_accu, &tv_thread_accu); } time_global = tv_thread_accu.tv_sec * 1000000 + tv_thread_accu.tv_usec; @@ -270,7 +239,7 @@ static int lt_stats_show_thread(struct lt_config_app *cfg, struct lt_thread *t) PRINT_VERBOSE(cfg, 1, "%s\n", "printing"); - tv_sub(&tv_thread_real, &t->tv_stop, &t->tv_start); + timersub(&t->tv_stop, &t->tv_start, &tv_thread_real); printf("\nThread %d (runtime %u.%06u sec)\n", t->tid, (u_int) tv_thread_real.tv_sec, (u_int) tv_thread_real.tv_usec); printf("%3s %-6s %10s %10s %10s %-30s\n", @@ -311,7 +280,7 @@ int lt_stats_show(struct lt_config_app *cfg) struct lt_thread *t; struct timeval tv_program_real; - tv_sub(&tv_program_real, &tv_program_stop, &tv_program_start); + timersub(&tv_program_stop, &tv_program_start, &tv_program_real); printf("\n--------------------------------------------------------------------------\n"); printf("Statistics for [%s] total runtime: %u.%06u sec\n", -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor