forked from localhorst/reHDD
cal metric: shred speed
This commit is contained in:
@ -64,6 +64,8 @@ int Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
}
|
||||
|
||||
this->ulDriveByteSize = getDriveSizeInBytes(driveFileDiscr);
|
||||
drive->sShredSpeed.chronoShredTimestamp = std::chrono::system_clock::now();; //set inital timestamp for speed metric
|
||||
unsigned long ulSpeedMetricBytesWritten = 0U; //uses to calculate speed metric
|
||||
|
||||
#ifdef LOG_LEVEL_HIGH
|
||||
Logger::logThis()->info("Shred-Task: Bytes-Size of Drive: " + to_string(this->ulDriveByteSize) + " - Drive: " + drive->getSerial());
|
||||
@ -73,6 +75,7 @@ int Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
{
|
||||
unsigned long ulDriveByteCounter = 0U; //used for one shred-iteration to keep track of the current drive position
|
||||
uint32_t u32ChunkDimensionIndex = 0U;
|
||||
|
||||
|
||||
if(uiShredIterationCounter == (SHRED_ITERATIONS-1))
|
||||
{
|
||||
@ -136,14 +139,25 @@ int Shred::shredDrive(Drive* drive, int* ipSignalFd)
|
||||
ulDriveByteCounter += iByteShredded;
|
||||
ulDriveByteOverallCount += iByteShredded;
|
||||
d32Percent = this->calcProgress();
|
||||
ulSpeedMetricBytesWritten += iByteShredded;
|
||||
|
||||
#ifdef LOG_LEVEL_HIGH
|
||||
Logger::logThis()->info("Shred-Task: ByteCount: " + to_string(ulDriveByteCounter) + " - iteration: " + to_string((uiShredIterationCounter+1)) + " - progress: " + to_string(d32Percent) + " - Drive: " + drive->getSerial());
|
||||
#endif
|
||||
if((d32Percent-d32TmpPercent) >= 0.01)
|
||||
{
|
||||
//set shred percantage
|
||||
drive->setTaskPercentage(d32TmpPercent);
|
||||
d32TmpPercent = d32Percent;
|
||||
|
||||
//set metrics for calculating shred speed
|
||||
std::chrono::time_point<std::chrono::system_clock> chronoCurrentTimestamp = std::chrono::system_clock::now();
|
||||
drive->sShredSpeed.u32ShredTimeDelta = (chronoCurrentTimestamp - drive->sShredSpeed.chronoShredTimestamp).count();
|
||||
drive->sShredSpeed.chronoShredTimestamp = std::chrono::system_clock::now();
|
||||
drive->sShredSpeed.ulWrittenBytes = ulSpeedMetricBytesWritten;
|
||||
ulSpeedMetricBytesWritten = 0U;
|
||||
|
||||
//signal process in shreding
|
||||
write(*ipSignalFd, "A",1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user