Browse Source

Don't mix timers with timestamps (visual only)

Luke Dashjr 12 years ago
parent
commit
f8cf2b71e6
4 changed files with 9 additions and 5 deletions
  1. 1 1
      driver-opencl.c
  2. 2 1
      logging.c
  3. 5 3
      miner.c
  4. 1 0
      miner.h

+ 1 - 1
driver-opencl.c

@@ -888,7 +888,7 @@ void opencl_wlogprint_status(struct cgpu_info *cgpu)
 		if (thr->cgpu != cgpu)
 		if (thr->cgpu != cgpu)
 			continue;
 			continue;
 		
 		
-		get_datestamp(checkin, thr->last.tv_sec);
+		get_datestamp(checkin, time(NULL) - timer_elapsed(&thr->last, NULL));
 		displayed_rolling = thr->rolling;
 		displayed_rolling = thr->rolling;
 		if (!mhash_base)
 		if (!mhash_base)
 			displayed_rolling *= 1000;
 			displayed_rolling *= 1000;

+ 2 - 1
logging.c

@@ -75,7 +75,8 @@ void _applog(int prio, const char *str)
 			struct timeval tv;
 			struct timeval tv;
 			struct tm tm;
 			struct tm tm;
 			
 			
-			cgtime(&tv);
+			// NOTE: cgtime is for timers, not time of day!
+			gettimeofday(&tv, NULL);
 			localtime_r(&tv.tv_sec, &tm);
 			localtime_r(&tv.tv_sec, &tm);
 			
 			
 			sprintf(datetime, "[%d-%02d-%02d %02d:%02d:%02d.%06ld]",
 			sprintf(datetime, "[%d-%02d-%02d %02d:%02d:%02d.%06ld]",

+ 5 - 3
miner.c

@@ -3160,9 +3160,11 @@ static bool submit_upstream_work_completed(struct work *work, bool resubmit, str
 	int thr_id = work->thr_id;
 	int thr_id = work->thr_id;
 	struct pool *pool = work->pool;
 	struct pool *pool = work->pool;
 	struct timeval tv_submit_reply;
 	struct timeval tv_submit_reply;
+	time_t ts_submit_reply;
 	char worktime[200] = "";
 	char worktime[200] = "";
 
 
 	cgtime(&tv_submit_reply);
 	cgtime(&tv_submit_reply);
+	ts_submit_reply = time(NULL);
 
 
 	if (unlikely(!val)) {
 	if (unlikely(!val)) {
 		applog(LOG_INFO, "submit_upstream_work json_rpc_call failed");
 		applog(LOG_INFO, "submit_upstream_work json_rpc_call failed");
@@ -3195,9 +3197,9 @@ static bool submit_upstream_work_completed(struct work *work, bool resubmit, str
 			double submit_time = tdiff(&tv_submit_reply, ptv_submit);
 			double submit_time = tdiff(&tv_submit_reply, ptv_submit);
 			int diffplaces = 3;
 			int diffplaces = 3;
 
 
-			localtime_r(&(work->tv_getwork.tv_sec), tm);
+			localtime_r(&work->ts_getwork, tm);
 			memcpy(&tm_getwork, tm, sizeof(struct tm));
 			memcpy(&tm_getwork, tm, sizeof(struct tm));
-			localtime_r(&(tv_submit_reply.tv_sec), tm);
+			localtime_r(&ts_submit_reply, tm);
 			memcpy(&tm_submit_reply, tm, sizeof(struct tm));
 			memcpy(&tm_submit_reply, tm, sizeof(struct tm));
 
 
 			if (work->clone) {
 			if (work->clone) {
@@ -9476,7 +9478,7 @@ begin_bench:
 		localtime_r(&miner_start_ts, &schedstart.tm);
 		localtime_r(&miner_start_ts, &schedstart.tm);
 	if (schedstop.tm.tm_sec)
 	if (schedstop.tm.tm_sec)
 		localtime_r(&miner_start_ts, &schedstop .tm);
 		localtime_r(&miner_start_ts, &schedstop .tm);
-	get_datestamp(datestamp, total_tv_start.tv_sec);
+	get_datestamp(datestamp, miner_start_ts);
 
 
 	// Initialise processors and threads
 	// Initialise processors and threads
 	k = 0;
 	k = 0;

+ 1 - 0
miner.h

@@ -1239,6 +1239,7 @@ struct work {
 	bool		do_foreign_submit;
 	bool		do_foreign_submit;
 
 
 	struct timeval	tv_getwork;
 	struct timeval	tv_getwork;
+	time_t		ts_getwork;
 	struct timeval	tv_getwork_reply;
 	struct timeval	tv_getwork_reply;
 	struct timeval	tv_cloned;
 	struct timeval	tv_cloned;
 	struct timeval	tv_work_start;
 	struct timeval	tv_work_start;