mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
added display of hashing speed. Changed hashing buffer size to 10MB to improve performance
This commit is contained in:
parent
2e9f5202e0
commit
3bb694f439
4 changed files with 49 additions and 21 deletions
|
@ -536,7 +536,10 @@ bool RsDirUtil::getFileHash(const std::string& filepath, RsFileHash &hash, uint6
|
|||
int len;
|
||||
SHA_CTX *sha_ctx = new SHA_CTX;
|
||||
unsigned char sha_buf[SHA_DIGEST_LENGTH];
|
||||
unsigned char gblBuf[512];
|
||||
|
||||
static const uint32_t HASH_BUFFER_SIZE = 1024*1024*10 ;// allocate a 10MB buffer. Too small a buffer will cause multiple HD hits and slow down the hashing process.
|
||||
RsTemporaryMemory gblBuf(HASH_BUFFER_SIZE) ;
|
||||
//unsigned char gblBuf[512];
|
||||
|
||||
/* determine size */
|
||||
fseeko64(fd, 0, SEEK_END);
|
||||
|
@ -548,7 +551,7 @@ bool RsDirUtil::getFileHash(const std::string& filepath, RsFileHash &hash, uint6
|
|||
int runningCheckCount = 0;
|
||||
|
||||
SHA1_Init(sha_ctx);
|
||||
while(isRunning && (len = fread(gblBuf,1, 512, fd)) > 0)
|
||||
while(isRunning && (len = fread(gblBuf,1, HASH_BUFFER_SIZE, fd)) > 0)
|
||||
{
|
||||
SHA1_Update(sha_ctx, gblBuf, len);
|
||||
|
||||
|
|
|
@ -43,8 +43,7 @@ public:
|
|||
void start();
|
||||
double duration();
|
||||
|
||||
private:
|
||||
double currentTime();
|
||||
static double currentTime();
|
||||
|
||||
private:
|
||||
std::string _name ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue