mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 01:50:10 +00:00
Increase benchmark accuracy by using a result based on the last meassured speed after benchmark values changed by less than 0.1% after kernel repeats
Goal is a "what you see is what you get" value compared to: "singlehash -a 3 ?b?b?b?b?b?b?b" -- both with the same fixed -u and -n values As a positive side-effect, this decreases total benchmark runtime Add speed_cnt_total and speed_ms_total as a preparation to get rid of SPEED_MAXAGE which produces 0H/s display on very slow-hash types Replace some floats with double which can (theoretically) become really big
This commit is contained in:
parent
01baa89bc0
commit
96ef261326
@ -955,9 +955,18 @@ struct __hc_device_param
|
||||
uint exec_pos;
|
||||
double exec_ms[EXEC_CACHE];
|
||||
|
||||
// this is "average" speed, we'll use this for benchmark and final status screen
|
||||
|
||||
u64 speed_cnt_total;
|
||||
double speed_ms_total;
|
||||
|
||||
// this is "current" speed
|
||||
|
||||
uint speed_pos;
|
||||
u64 speed_cnt[SPEED_CACHE];
|
||||
float speed_ms[SPEED_CACHE];
|
||||
double speed_ms[SPEED_CACHE];
|
||||
|
||||
// speed_rec is what additionally limits the "current" speed in time, not array elements
|
||||
|
||||
hc_timer_t speed_rec[SPEED_CACHE];
|
||||
|
||||
@ -1291,7 +1300,7 @@ typedef struct
|
||||
hc_timer_t timer_running; // timer on current dict
|
||||
hc_timer_t timer_paused; // timer on current dict
|
||||
|
||||
float ms_paused; // timer on current dict
|
||||
double ms_paused; // timer on current dict
|
||||
|
||||
/**
|
||||
* hash_info and username
|
||||
|
@ -33,7 +33,7 @@ double TARGET_MS_PROFILE[3] = { 8, 16, 96 };
|
||||
#define MARKOV_DISABLE 0
|
||||
#define MARKOV_CLASSIC 0
|
||||
#define BENCHMARK 0
|
||||
#define BENCHMARK_REPEATS 2
|
||||
#define BENCHMARK_REPEATS 100
|
||||
#define RESTORE 0
|
||||
#define RESTORE_TIMER 60
|
||||
#define RESTORE_DISABLE 0
|
||||
@ -801,11 +801,11 @@ void status_display_automat ()
|
||||
if (device_param->skipped) continue;
|
||||
|
||||
u64 speed_cnt = 0;
|
||||
float speed_ms = 0;
|
||||
double speed_ms = 0;
|
||||
|
||||
for (int i = 0; i < SPEED_CACHE; i++)
|
||||
{
|
||||
float rec_ms;
|
||||
double rec_ms;
|
||||
|
||||
hc_timer_get (device_param->speed_rec[i], rec_ms);
|
||||
|
||||
@ -1141,7 +1141,7 @@ void status_display ()
|
||||
*/
|
||||
|
||||
u64 speed_cnt[DEVICES_MAX] = { 0 };
|
||||
float speed_ms[DEVICES_MAX] = { 0 };
|
||||
double speed_ms[DEVICES_MAX] = { 0 };
|
||||
|
||||
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
|
||||
{
|
||||
@ -1162,7 +1162,7 @@ void status_display ()
|
||||
|
||||
for (int i = 0; i < SPEED_CACHE; i++)
|
||||
{
|
||||
float rec_ms;
|
||||
double rec_ms;
|
||||
|
||||
hc_timer_get (device_param->speed_rec[i], rec_ms);
|
||||
|
||||
@ -1217,15 +1217,15 @@ void status_display ()
|
||||
* timers
|
||||
*/
|
||||
|
||||
float ms_running = 0;
|
||||
double ms_running = 0;
|
||||
|
||||
hc_timer_get (data.timer_running, ms_running);
|
||||
|
||||
float ms_paused = data.ms_paused;
|
||||
double ms_paused = data.ms_paused;
|
||||
|
||||
if (data.devices_status == STATUS_PAUSED)
|
||||
{
|
||||
float ms_paused_tmp = 0;
|
||||
double ms_paused_tmp = 0;
|
||||
|
||||
hc_timer_get (data.timer_paused, ms_paused_tmp);
|
||||
|
||||
@ -1472,7 +1472,7 @@ void status_display ()
|
||||
}
|
||||
}
|
||||
|
||||
float ms_real = ms_running - ms_paused;
|
||||
double ms_real = ms_running - ms_paused;
|
||||
|
||||
float cpt_avg_min = (float) data.cpt_total / ((ms_real / 1000) / 60);
|
||||
float cpt_avg_hour = (float) data.cpt_total / ((ms_real / 1000) / 3600);
|
||||
@ -1632,7 +1632,7 @@ static void status_benchmark ()
|
||||
if (data.words_cnt == 0) return;
|
||||
|
||||
u64 speed_cnt[DEVICES_MAX] = { 0 };
|
||||
float speed_ms[DEVICES_MAX] = { 0 };
|
||||
double speed_ms[DEVICES_MAX] = { 0 };
|
||||
|
||||
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
|
||||
{
|
||||
@ -1640,17 +1640,8 @@ static void status_benchmark ()
|
||||
|
||||
if (device_param->skipped) continue;
|
||||
|
||||
speed_cnt[device_id] = 0;
|
||||
speed_ms[device_id] = 0;
|
||||
|
||||
for (int i = 0; i < SPEED_CACHE; i++)
|
||||
{
|
||||
speed_cnt[device_id] += device_param->speed_cnt[i];
|
||||
speed_ms[device_id] += device_param->speed_ms[i];
|
||||
}
|
||||
|
||||
speed_cnt[device_id] /= SPEED_CACHE;
|
||||
speed_ms[device_id] /= SPEED_CACHE;
|
||||
speed_cnt[device_id] = device_param->speed_cnt[0];
|
||||
speed_ms[device_id] = device_param->speed_ms[0];
|
||||
}
|
||||
|
||||
float hashes_all_ms = 0;
|
||||
@ -2465,7 +2456,7 @@ static void run_kernel (const uint kern_run, hc_device_param_t *device_param, co
|
||||
|
||||
if (event_update)
|
||||
{
|
||||
float exec_time;
|
||||
double exec_time;
|
||||
|
||||
hc_timer_get (timer, exec_time);
|
||||
|
||||
@ -3303,9 +3294,34 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
|
||||
|
||||
if (data.benchmark == 1)
|
||||
{
|
||||
for (u32 i = 0; i < data.benchmark_repeats; i++)
|
||||
double exec_ms_avg_prev = get_avg_exec_time (device_param, EXEC_CACHE);
|
||||
|
||||
// a few caching rounds
|
||||
|
||||
for (u32 i = 0; i < 2; i++)
|
||||
{
|
||||
hc_timer_set (&device_param->timer_speed);
|
||||
|
||||
choose_kernel (device_param, data.attack_exec, data.attack_mode, data.opts_type, salt_buf, highest_pw_len, pws_cnt);
|
||||
|
||||
double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE);
|
||||
|
||||
exec_ms_avg_prev = exec_ms_avg;
|
||||
}
|
||||
|
||||
// benchmark_repeats became a maximum possible repeats
|
||||
|
||||
for (u32 i = 2; i < data.benchmark_repeats; i++)
|
||||
{
|
||||
hc_timer_set (&device_param->timer_speed);
|
||||
|
||||
choose_kernel (device_param, data.attack_exec, data.attack_mode, data.opts_type, salt_buf, highest_pw_len, pws_cnt);
|
||||
|
||||
double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE);
|
||||
|
||||
if ((exec_ms_avg_prev / exec_ms_avg) < 1.001) break;
|
||||
|
||||
exec_ms_avg_prev = exec_ms_avg;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3331,11 +3347,6 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
|
||||
|
||||
u64 perf_sum_all = (u64) pws_cnt * (u64) innerloop_left;
|
||||
|
||||
if (data.benchmark == 1)
|
||||
{
|
||||
perf_sum_all = (perf_sum_all * data.benchmark_repeats) + perf_sum_all;
|
||||
}
|
||||
|
||||
hc_thread_mutex_lock (mux_counter);
|
||||
|
||||
data.words_progress_done[salt_pos] += perf_sum_all;
|
||||
@ -3346,7 +3357,7 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
|
||||
* speed
|
||||
*/
|
||||
|
||||
float speed_ms;
|
||||
double speed_ms;
|
||||
|
||||
hc_timer_get (device_param->timer_speed, speed_ms);
|
||||
|
||||
@ -3354,6 +3365,8 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
|
||||
|
||||
hc_thread_mutex_lock (mux_display);
|
||||
|
||||
// current speed
|
||||
|
||||
device_param->speed_cnt[speed_pos] = perf_sum_all;
|
||||
|
||||
device_param->speed_ms[speed_pos] = speed_ms;
|
||||
@ -3369,6 +3382,12 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
|
||||
speed_pos = 0;
|
||||
}
|
||||
|
||||
// average speed
|
||||
|
||||
device_param->speed_cnt_total += perf_sum_all;
|
||||
|
||||
device_param->speed_ms_total += speed_ms;
|
||||
|
||||
/**
|
||||
* benchmark
|
||||
*/
|
||||
@ -14785,7 +14804,7 @@ int main (int argc, char **argv)
|
||||
if (data.quiet == 0) log_info ("");
|
||||
|
||||
/**
|
||||
* Inform user which algorithm is checked and at which workload setting
|
||||
* In benchmark-mode, inform user which algorithm is checked
|
||||
*/
|
||||
|
||||
if (benchmark == 1)
|
||||
@ -16013,9 +16032,12 @@ int main (int argc, char **argv)
|
||||
device_param->speed_pos = 0;
|
||||
|
||||
memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (u64));
|
||||
memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (float));
|
||||
memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (double));
|
||||
memset (device_param->speed_rec, 0, SPEED_CACHE * sizeof (hc_timer_t));
|
||||
|
||||
device_param->speed_cnt_total = 0;
|
||||
device_param->speed_ms_total = 0;
|
||||
|
||||
device_param->exec_pos = 0;
|
||||
|
||||
memset (device_param->exec_ms, 0, EXEC_CACHE * sizeof (double));
|
||||
|
@ -8816,7 +8816,7 @@ void ResumeThreads ()
|
||||
{
|
||||
if (data.devices_status == STATUS_PAUSED)
|
||||
{
|
||||
float ms_paused;
|
||||
double ms_paused;
|
||||
|
||||
hc_timer_get (data.timer_paused, ms_paused);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user