mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 20:44:19 +00:00
Provide wrappers for commonly used timer routines with API stats.
This commit is contained in:
parent
170a4aeb26
commit
d2abaa8317
34
cgminer.c
34
cgminer.c
@ -5653,34 +5653,22 @@ static void hash_sole_work(struct thr_info *mythr)
|
||||
do {
|
||||
cgtime(&tv_start);
|
||||
|
||||
timersub(&tv_start, &getwork_start, &getwork_start);
|
||||
subtime(&tv_start, &getwork_start);
|
||||
|
||||
timeradd(&getwork_start,
|
||||
&(dev_stats->getwork_wait),
|
||||
&(dev_stats->getwork_wait));
|
||||
if (timercmp(&getwork_start, &(dev_stats->getwork_wait_max), >)) {
|
||||
dev_stats->getwork_wait_max.tv_sec = getwork_start.tv_sec;
|
||||
dev_stats->getwork_wait_max.tv_usec = getwork_start.tv_usec;
|
||||
}
|
||||
if (timercmp(&getwork_start, &(dev_stats->getwork_wait_min), <)) {
|
||||
dev_stats->getwork_wait_min.tv_sec = getwork_start.tv_sec;
|
||||
dev_stats->getwork_wait_min.tv_usec = getwork_start.tv_usec;
|
||||
}
|
||||
addtime(&getwork_start, &dev_stats->getwork_wait);
|
||||
if (time_more(&getwork_start, &dev_stats->getwork_wait_max))
|
||||
copy_time(&dev_stats->getwork_wait_max, &getwork_start);
|
||||
if (time_less(&getwork_start, &dev_stats->getwork_wait_min))
|
||||
copy_time(&dev_stats->getwork_wait_min, &getwork_start);
|
||||
dev_stats->getwork_calls++;
|
||||
|
||||
pool_stats = &(work->pool->cgminer_stats);
|
||||
|
||||
timeradd(&getwork_start,
|
||||
&(pool_stats->getwork_wait),
|
||||
&(pool_stats->getwork_wait));
|
||||
if (timercmp(&getwork_start, &(pool_stats->getwork_wait_max), >)) {
|
||||
pool_stats->getwork_wait_max.tv_sec = getwork_start.tv_sec;
|
||||
pool_stats->getwork_wait_max.tv_usec = getwork_start.tv_usec;
|
||||
}
|
||||
if (timercmp(&getwork_start, &(pool_stats->getwork_wait_min), <)) {
|
||||
pool_stats->getwork_wait_min.tv_sec = getwork_start.tv_sec;
|
||||
pool_stats->getwork_wait_min.tv_usec = getwork_start.tv_usec;
|
||||
}
|
||||
addtime(&getwork_start, &pool_stats->getwork_wait);
|
||||
if (time_more(&getwork_start, &pool_stats->getwork_wait_max))
|
||||
copy_time(&pool_stats->getwork_wait_max, &getwork_start);
|
||||
if (time_less(&getwork_start, &pool_stats->getwork_wait_min))
|
||||
copy_time(&pool_stats->getwork_wait_min, &getwork_start);
|
||||
pool_stats->getwork_calls++;
|
||||
|
||||
cgtime(&(work->tv_work_start));
|
||||
|
25
util.c
25
util.c
@ -852,6 +852,31 @@ void cgtime(struct timeval *tv)
|
||||
#endif
|
||||
}
|
||||
|
||||
void subtime(struct timeval *a, struct timeval *b)
|
||||
{
|
||||
timersub(a, b, b);
|
||||
}
|
||||
|
||||
void addtime(struct timeval *a, struct timeval *b)
|
||||
{
|
||||
timeradd(a, b, b);
|
||||
}
|
||||
|
||||
bool time_more(struct timeval *a, struct timeval *b)
|
||||
{
|
||||
return timercmp(a, b, >);
|
||||
}
|
||||
|
||||
bool time_less(struct timeval *a, struct timeval *b)
|
||||
{
|
||||
return timercmp(a, b, <);
|
||||
}
|
||||
|
||||
void copy_time(struct timeval *dest, const struct timeval *src)
|
||||
{
|
||||
memcpy(dest, src, sizeof(struct timeval));
|
||||
}
|
||||
|
||||
/* Returns the microseconds difference between end and start times as a double */
|
||||
double us_tdiff(struct timeval *end, struct timeval *start)
|
||||
{
|
||||
|
5
util.h
5
util.h
@ -51,6 +51,11 @@ void thr_info_freeze(struct thr_info *thr);
|
||||
void thr_info_cancel(struct thr_info *thr);
|
||||
void nmsleep(unsigned int msecs);
|
||||
void cgtime(struct timeval *tv);
|
||||
void subtime(struct timeval *a, struct timeval *b);
|
||||
void addtime(struct timeval *a, struct timeval *b);
|
||||
bool time_more(struct timeval *a, struct timeval *b);
|
||||
bool time_less(struct timeval *a, struct timeval *b);
|
||||
void copy_time(struct timeval *dest, const struct timeval *src);
|
||||
double us_tdiff(struct timeval *end, struct timeval *start);
|
||||
double tdiff(struct timeval *end, struct timeval *start);
|
||||
bool stratum_send(struct pool *pool, char *s, ssize_t len);
|
||||
|
Loading…
x
Reference in New Issue
Block a user