mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-22 06:38:11 +00:00
Replaced timer macros with inlines
This commit is contained in:
parent
ac3b850e40
commit
743dba56db
@ -6,16 +6,7 @@
|
||||
#ifndef _TIMER_H
|
||||
#define _TIMER_H
|
||||
|
||||
#if defined (_WIN)
|
||||
|
||||
#define hc_timer_get(a,r) { hc_timer_t hr_freq; QueryPerformanceFrequency (&hr_freq); hc_timer_t hr_tmp; hc_timer_set (&hr_tmp); (r) = (double) ((double) (hr_tmp.QuadPart - (a).QuadPart) / (double) (hr_freq.QuadPart / 1000)); }
|
||||
#define hc_timer_set(a) { QueryPerformanceCounter ((a)); }
|
||||
|
||||
#elif defined (_POSIX)
|
||||
|
||||
#define hc_timer_get(a,r) { hc_timer_t hr_tmp; hc_timer_set (&hr_tmp); (r) = (double) (((hr_tmp.tv_sec - (a).tv_sec) * 1000) + ((double) (hr_tmp.tv_usec - (a).tv_usec) / 1000)); }
|
||||
#define hc_timer_set(a) { gettimeofday ((a), NULL); }
|
||||
|
||||
#endif
|
||||
void hc_timer_set (hc_timer_t *a);
|
||||
double hc_timer_get (hc_timer_t a);
|
||||
|
||||
#endif // _TIMER_H
|
||||
|
@ -291,9 +291,7 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (status_ctx->devices_status == STATUS_PAUSED)
|
||||
{
|
||||
double ms_paused_tmp = 0;
|
||||
|
||||
hc_timer_get (status_ctx->timer_paused, ms_paused_tmp);
|
||||
double ms_paused_tmp = hc_timer_get (status_ctx->timer_paused);
|
||||
|
||||
ms_paused += ms_paused_tmp;
|
||||
}
|
||||
|
@ -380,9 +380,7 @@ int choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, co
|
||||
|
||||
const u64 perf_sum_all = (u64) (pws_cnt * iter_part);
|
||||
|
||||
double speed_ms;
|
||||
|
||||
hc_timer_get (device_param->timer_speed, speed_ms);
|
||||
double speed_ms = hc_timer_get (device_param->timer_speed);
|
||||
|
||||
const u32 speed_pos = device_param->speed_pos;
|
||||
|
||||
@ -1304,9 +1302,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
|
||||
* speed
|
||||
*/
|
||||
|
||||
double speed_ms;
|
||||
|
||||
hc_timer_get (device_param->timer_speed, speed_ms);
|
||||
double speed_ms = hc_timer_get (device_param->timer_speed);
|
||||
|
||||
hc_timer_set (&device_param->timer_speed);
|
||||
|
||||
|
@ -602,17 +602,13 @@ void status_display (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const h
|
||||
* timers
|
||||
*/
|
||||
|
||||
double ms_running = 0;
|
||||
|
||||
hc_timer_get (status_ctx->timer_running, ms_running);
|
||||
double ms_running = hc_timer_get (status_ctx->timer_running);
|
||||
|
||||
double ms_paused = status_ctx->ms_paused;
|
||||
|
||||
if (status_ctx->devices_status == STATUS_PAUSED)
|
||||
{
|
||||
double ms_paused_tmp = 0;
|
||||
|
||||
hc_timer_get (status_ctx->timer_paused, ms_paused_tmp);
|
||||
double ms_paused_tmp = hc_timer_get (status_ctx->timer_paused);
|
||||
|
||||
ms_paused += ms_paused_tmp;
|
||||
}
|
||||
|
@ -186,9 +186,7 @@ void ResumeThreads (status_ctx_t *status_ctx)
|
||||
{
|
||||
if (status_ctx->devices_status != STATUS_PAUSED) return;
|
||||
|
||||
double ms_paused;
|
||||
|
||||
hc_timer_get (status_ctx->timer_paused, ms_paused);
|
||||
double ms_paused = hc_timer_get (status_ctx->timer_paused);
|
||||
|
||||
status_ctx->ms_paused += ms_paused;
|
||||
|
||||
|
39
src/timer.c
39
src/timer.c
@ -4,4 +4,43 @@
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "timer.h"
|
||||
|
||||
#if defined (_WIN)
|
||||
|
||||
inline void hc_timer_set (hc_timer_t *a)
|
||||
{
|
||||
QueryPerformanceCounter (a);
|
||||
}
|
||||
|
||||
inline double hc_timer_get (hc_timer_t a)
|
||||
{
|
||||
hc_timer_t hr_freq;
|
||||
|
||||
QueryPerformanceFrequency (&hr_freq);
|
||||
|
||||
hc_timer_t hr_tmp;
|
||||
|
||||
hc_timer_set (&hr_tmp);
|
||||
|
||||
return (double) ((double) (hr_tmp.QuadPart - a.QuadPart) / (double) (hr_freq.QuadPart / 1000));
|
||||
}
|
||||
|
||||
#elif defined(_POSIX)
|
||||
|
||||
inline void hc_timer_set (hc_timer_t* a)
|
||||
{
|
||||
gettimeofday (a, NULL);
|
||||
}
|
||||
|
||||
inline double hc_timer_get (hc_timer_t a)
|
||||
{
|
||||
hc_timer_t hr_tmp;
|
||||
|
||||
hc_timer_set (&hr_tmp);
|
||||
|
||||
return (double) (((hr_tmp.tv_sec - (a).tv_sec) * 1000) + ((double) (hr_tmp.tv_usec - (a).tv_usec) / 1000));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user