mirror of
https://github.com/GOSTSec/ccminer
synced 2025-01-10 14:57:53 +00:00
stats: rework stats map key to fix sort order
to fix histo api command without param
This commit is contained in:
parent
7bb86defcc
commit
1fcdeab53b
20
stats.cpp
20
stats.cpp
@ -26,8 +26,8 @@ extern int device_map[8];
|
||||
*/
|
||||
void stats_remember_speed(int thr_id, uint32_t hashcount, double hashrate, uint8_t found, uint32_t height)
|
||||
{
|
||||
uint64_t gpu = device_map[thr_id];
|
||||
uint64_t key = (gpu << 56) + (uid++ % UINT32_MAX);
|
||||
const uint8_t gpu = (uint8_t) device_map[thr_id];
|
||||
const uint64_t key = ((uid++ % UINT32_MAX) << 32) + gpu;
|
||||
stats_data data;
|
||||
// to enough hashes to give right stats
|
||||
if (hashcount < 1000 || hashrate < 0.01)
|
||||
@ -38,7 +38,7 @@ void stats_remember_speed(int thr_id, uint32_t hashcount, double hashrate, uint8
|
||||
return;
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.gpu_id = (uint8_t)gpu;
|
||||
data.gpu_id = gpu;
|
||||
data.thr_id = (uint8_t)thr_id;
|
||||
data.tm_stat = (uint32_t) time(NULL);
|
||||
data.height = height;
|
||||
@ -61,16 +61,15 @@ void stats_remember_speed(int thr_id, uint32_t hashcount, double hashrate, uint8
|
||||
*/
|
||||
double stats_get_speed(int thr_id, double def_speed)
|
||||
{
|
||||
uint64_t gpu = device_map[thr_id];
|
||||
uint64_t keypfx = (gpu << 56);
|
||||
uint64_t keymsk = (0xffULL << 56);
|
||||
const uint64_t gpu = device_map[thr_id];
|
||||
const uint64_t keymsk = 0xffULL; // last u8 is the gpu
|
||||
double speed = 0.0;
|
||||
int records = 0;
|
||||
|
||||
std::map<uint64_t, stats_data>::reverse_iterator i = tlastscans.rbegin();
|
||||
while (i != tlastscans.rend() && records < opt_statsavg) {
|
||||
if (!i->second.ignored)
|
||||
if (thr_id == -1 || (keymsk & i->first) == keypfx) {
|
||||
if (thr_id == -1 || (keymsk & i->first) == gpu) {
|
||||
if (i->second.hashcount > 1000) {
|
||||
speed += i->second.hashrate;
|
||||
records++;
|
||||
@ -93,16 +92,15 @@ double stats_get_speed(int thr_id, double def_speed)
|
||||
|
||||
int stats_get_history(int thr_id, struct stats_data *data, int max_records)
|
||||
{
|
||||
uint64_t gpu = device_map[thr_id];
|
||||
uint64_t keypfx = (gpu << 56);
|
||||
uint64_t keymsk = (0xffULL << 56);
|
||||
const uint64_t gpu = device_map[thr_id];
|
||||
const uint64_t keymsk = 0xffULL; // last u8 is the gpu
|
||||
double speed = 0.0;
|
||||
int records = 0;
|
||||
|
||||
std::map<uint64_t, stats_data>::reverse_iterator i = tlastscans.rbegin();
|
||||
while (i != tlastscans.rend() && records < max_records) {
|
||||
if (!i->second.ignored)
|
||||
if (thr_id == -1 || (keymsk & i->first) == keypfx) {
|
||||
if (thr_id == -1 || (keymsk & i->first) == gpu) {
|
||||
memcpy(&data[records], &(i->second), sizeof(struct stats_data));
|
||||
records++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user