diff --git a/include/status.h b/include/status.h index 29b8ce72f..c4fb57b66 100644 --- a/include/status.h +++ b/include/status.h @@ -58,6 +58,7 @@ u64 status_get_progress_cur_relative_skip (const hashcat_ctx_t *hashcat_ctx) u64 status_get_progress_end_relative_skip (const hashcat_ctx_t *hashcat_ctx); double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx); double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +double status_get_hashes_msec_dev_benchmark (const hashcat_ctx_t *hashcat_ctx, const int device_id); double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx); double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); char *status_get_speed_sec_all (const hashcat_ctx_t *hashcat_ctx); diff --git a/src/status.c b/src/status.c index bfb521971..9680362e6 100644 --- a/src/status.c +++ b/src/status.c @@ -1127,6 +1127,33 @@ double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int d return hashes_dev_msec; } +double status_get_hashes_msec_dev_benchmark (const hashcat_ctx_t *hashcat_ctx, const int device_id) +{ + // this function increases accuracy for benchmark modes + + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + u64 speed_cnt = 0; + double speed_msec = 0; + + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped == false) + { + speed_cnt += device_param->speed_cnt[0]; + speed_msec += device_param->speed_msec[0]; + } + + double hashes_dev_msec = 0; + + if (speed_msec > 0) + { + hashes_dev_msec = (double) speed_cnt / speed_msec; + } + + return hashes_dev_msec; +} + double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx) { const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; diff --git a/src/terminal.c b/src/terminal.c index 67f351ad6..b8692967f 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -785,59 +785,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - if (status_ctx->devices_status == STATUS_INIT) - { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); - - return; - } - - if (status_ctx->devices_status == STATUS_AUTOTUNE) - { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); - - return; - } - - u64 speed_cnt[DEVICES_MAX] = { 0 }; - double speed_msec[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; + const u32 hash_mode = hashconfig->hash_mode; - speed_cnt[device_id] = device_param->speed_cnt[0]; - speed_msec[device_id] = device_param->speed_msec[0]; - } - - u64 hashes_dev_msec[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - hashes_dev_msec[device_id] = 0; - - if (speed_msec[device_id] > 0) - { - hashes_dev_msec[device_id] = (double) speed_cnt[device_id] / speed_msec[device_id]; - } - } - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + for (int device_id = 0; device_id < status_get_device_info_cnt (hashcat_ctx); device_id++) { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; + if (status_get_skipped_dev (hashcat_ctx, device_id) == true) continue; - event_log_info (hashcat_ctx, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_msec[device_id] * 1000)); + event_log_info (hashcat_ctx, "%u:%u:%" PRIu64, device_id + 1, hash_mode, (u64) (status_get_hashes_msec_dev_benchmark (hashcat_ctx, device_id) * 1000)); } }