read random date in bulk to reduce syscalls

This commit is contained in:
2022-05-15 15:17:49 +02:00
parent 4fc44d9926
commit e49c1a231c
3 changed files with 78 additions and 48 deletions

View File

@ -17,11 +17,12 @@
#include <unistd.h>
#include <string.h>
#define CHUNK_SIZE 1024*1024*2 //amount of bytes that are overwritten at once
#define SHRED_ITERATIONS 3 //overwrite the drive multiple times, last time with zeros
#define CHUNK_DIMENSION 100U //amount of chunks are read at once from random source
//#define DEMO_DRIVE_SIZE 1024*1024*256 // 256MB
//#define DEMO_DRIVE_SIZE 1024*1024*256L // 256MB
//#define DEMO_DRIVE_SIZE 1024*1024*1024L // 1GB
#define DEMO_DRIVE_SIZE 1024*1024*1024*10L // 10GB
typedef int fileDescriptor;
@ -38,7 +39,7 @@ public:
private:
fileDescriptor randomSrcFileDiscr;
fileDescriptor driveFileDiscr;
unsigned char caChunk[CHUNK_SIZE];
unsigned char caChunk[CHUNK_DIMENSION][CHUNK_SIZE];
unsigned long ulDriveByteSize;
unsigned long ulDriveByteOverallCount = 0; //all bytes shredded in all iterations + checking -> used for progress calculation
double d32Percent = 0.0;