Provide a helper function for determining dev runtime and use it in the hashmeters used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
diff --git a/api.c b/api.c
index 546d3a6..4c1cba4 100644
--- a/api.c
+++ b/api.c
@@ -1943,15 +1943,7 @@ static void ascstatus(struct io_data *io_data, int asc, bool isjson, bool precom
struct timeval now;
double dev_runtime;
- if (cgpu->dev_start_tv.tv_sec == 0)
- dev_runtime = total_secs;
- else {
- cgtime(&now);
- dev_runtime = tdiff(&now, &(cgpu->dev_start_tv));
- }
-
- if (dev_runtime < 1.0)
- dev_runtime = 1.0;
+ dev_runtime = cgpu_runtime(cgpu);
cgpu->utility = cgpu->accepted / dev_runtime * 60;
diff --git a/cgminer.c b/cgminer.c
index e07aa90..8008939 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2131,12 +2131,10 @@ static void suffix_string(uint64_t val, char *buf, size_t bufsiz, int sigdigits)
}
}
-static void get_statline(char *buf, size_t bufsiz, struct cgpu_info *cgpu)
+double cgpu_runtime(struct cgpu_info *cgpu)
{
- char displayed_hashes[16], displayed_rolling[16];
- uint64_t dh64, dr64;
struct timeval now;
- double dev_runtime, wu;
+ double dev_runtime;
if (cgpu->dev_start_tv.tv_sec == 0)
dev_runtime = total_secs;
@@ -2147,6 +2145,16 @@ static void get_statline(char *buf, size_t bufsiz, struct cgpu_info *cgpu)
if (dev_runtime < 1.0)
dev_runtime = 1.0;
+ return dev_runtime;
+}
+
+static void get_statline(char *buf, size_t bufsiz, struct cgpu_info *cgpu)
+{
+ char displayed_hashes[16], displayed_rolling[16];
+ double dev_runtime, wu;
+ uint64_t dh64, dr64;
+
+ dev_runtime = cgpu_runtime(cgpu);
wu = cgpu->diff1 / dev_runtime * 60.0;
diff --git a/miner.h b/miner.h
index 0aac88b..dad0b00 100644
--- a/miner.h
+++ b/miner.h
@@ -660,6 +660,7 @@ endian_flip128(void __maybe_unused *dest_p, const void __maybe_unused *src_p)
}
#endif
+extern double cgpu_runtime(struct cgpu_info *cgpu);
extern void _quit(int status);
/*