Provide msclock() as Milliseconds timer for performance measures (#231)

- don't use clock(). It has different functionalities in Windows and Linux
- move sleep functions to util.h
This commit is contained in:
pwpiwi 2017-03-12 15:06:27 +01:00 committed by GitHub
commit acf0582d53
29 changed files with 162 additions and 150 deletions

View file

@ -9,8 +9,10 @@
//-----------------------------------------------------------------------------
#include <inttypes.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "proxmark3.h"
#include "cmdmain.h"
#include "util.h"
@ -688,8 +690,8 @@ int CmdHF14AMfNested(const char *Cmd)
}
}
else { // ------------------------------------ multiple sectors working
clock_t time1;
time1 = clock();
uint64_t msclock1;
msclock1 = msclock();
e_sector = calloc(SectorsCnt, sizeof(sector_t));
if (e_sector == NULL) return 1;
@ -759,7 +761,7 @@ int CmdHF14AMfNested(const char *Cmd)
}
}
printf("Time in nested: %1.3f (%1.3f sec per key)\n\n", ((float)clock() - time1)/CLOCKS_PER_SEC, ((float)clock() - time1)/iterations/CLOCKS_PER_SEC);
printf("Time in nested: %1.3f (%1.3f sec per key)\n\n", ((float)(msclock() - msclock1))/1000.0, ((float)(msclock() - msclock1))/iterations/1000.0);
PrintAndLog("-----------------------------------------------\nIterations count: %d\n\n", iterations);
//print them