Keep it simple: use only one structure and get_time function
This commit is contained in:
parent
60554855d8
commit
bf6ffd357d
|
|
@ -77,13 +77,10 @@ init_rlimits(void)
|
||||||
ft_ckspace();
|
ft_ckspace();
|
||||||
}
|
}
|
||||||
|
|
||||||
PerfTimer timer;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
init_time(void)
|
init_time(void)
|
||||||
{
|
{
|
||||||
perf_timer_get_time(&timebegin);
|
perf_timer_get_time(&timebegin);
|
||||||
perf_timer_start(&timer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -158,6 +155,7 @@ printres(char *name)
|
||||||
static bool called = FALSE;
|
static bool called = FALSE;
|
||||||
static long last_sec = 0, last_msec = 0;
|
static long last_sec = 0, last_msec = 0;
|
||||||
struct variable *v, *vfree = NULL;
|
struct variable *v, *vfree = NULL;
|
||||||
|
PerfTime timenow; /* actual time stamp */
|
||||||
char *cpu_elapsed;
|
char *cpu_elapsed;
|
||||||
|
|
||||||
if (!name || eq(name, "totalcputime") || eq(name, "cputime")) {
|
if (!name || eq(name, "totalcputime") || eq(name, "cputime")) {
|
||||||
|
|
@ -168,8 +166,9 @@ printres(char *name)
|
||||||
|| defined (HAVE_GETTIMEOFDAY) || defined(HAVE_TIMES) \
|
|| defined (HAVE_GETTIMEOFDAY) || defined(HAVE_TIMES) \
|
||||||
|| defined (HAVE_GETRUSAGE) || defined(HAVE_FTIME)
|
|| defined (HAVE_GETRUSAGE) || defined(HAVE_FTIME)
|
||||||
|
|
||||||
perf_timer_stop(&timer);
|
perf_timer_get_time(&timenow);
|
||||||
perf_timer_elapsed_sec_ms(&timer, &total_sec, &total_msec);
|
total_sec = timenow.seconds;
|
||||||
|
total_msec = timenow.milliseconds;
|
||||||
|
|
||||||
#ifdef USE_OMP // this order have to be same as
|
#ifdef USE_OMP // this order have to be same as
|
||||||
cpu_elapsed = "elapsed"; // the order in seconds() misc_time.c
|
cpu_elapsed = "elapsed"; // the order in seconds() misc_time.c
|
||||||
|
|
|
||||||
|
|
@ -159,23 +159,6 @@ seconds(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void perf_timer_start(PerfTimer *timer)
|
|
||||||
{
|
|
||||||
timer->start = seconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
void perf_timer_stop(PerfTimer *timer)
|
|
||||||
{
|
|
||||||
timer->end = seconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
void perf_timer_elapsed_sec_ms(const PerfTimer *timer, int *seconds, int *milliseconds)
|
|
||||||
{
|
|
||||||
double elapsed = timer->end - timer->start;
|
|
||||||
*seconds = (int)elapsed;
|
|
||||||
*milliseconds = (int)((elapsed - *seconds) * 1000.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void perf_timer_get_time(PerfTime *time)
|
void perf_timer_get_time(PerfTime *time)
|
||||||
{
|
{
|
||||||
time->secs = seconds();
|
time->secs = seconds();
|
||||||
|
|
|
||||||
|
|
@ -9,20 +9,12 @@
|
||||||
char * datestring(void);
|
char * datestring(void);
|
||||||
double seconds(void);
|
double seconds(void);
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
double start;
|
|
||||||
double end;
|
|
||||||
} PerfTimer;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double secs;
|
double secs;
|
||||||
int seconds;
|
int seconds;
|
||||||
int milliseconds;
|
int milliseconds;
|
||||||
} PerfTime;
|
} PerfTime;
|
||||||
|
|
||||||
void perf_timer_start(PerfTimer *);
|
|
||||||
void perf_timer_stop(PerfTimer *);
|
|
||||||
void perf_timer_elapsed_sec_ms(const PerfTimer *, int *, int *);
|
|
||||||
void perf_timer_get_time(PerfTime *);
|
void perf_timer_get_time(PerfTime *);
|
||||||
|
|
||||||
extern PerfTime timebegin;
|
extern PerfTime timebegin;
|
||||||
|
|
|
||||||
|
|
@ -1971,7 +1971,8 @@ void SetAnalyse(
|
||||||
|
|
||||||
/* get current time */
|
/* get current time */
|
||||||
perf_timer_get_time(&timenow);
|
perf_timer_get_time(&timenow);
|
||||||
timediff(&timenow, &timebefore, &diffsec, &diffmillisec);
|
diffsec = timenow.seconds;
|
||||||
|
diffmillisec = timenow.milliseconds;
|
||||||
|
|
||||||
s = TMALLOC(char, 128);
|
s = TMALLOC(char, 128);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,8 @@ SetAnalyse(char *Analyse, /* in: analysis type */
|
||||||
|
|
||||||
/* get actual time */
|
/* get actual time */
|
||||||
perf_timer_get_time(&timenow);
|
perf_timer_get_time(&timenow);
|
||||||
timediff(&timenow, &timebefore, &diffsec, &diffmillisec);
|
diffsec = timenow.seconds;
|
||||||
|
diffmillisec = timenow.milliseconds;
|
||||||
|
|
||||||
OldPercent = DecaPercent;
|
OldPercent = DecaPercent;
|
||||||
/* output only into hwAnalyse window and if time elapsed is larger than
|
/* output only into hwAnalyse window and if time elapsed is larger than
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue