Show size and time in real units.
This commit is contained in:
28
src/main.c
28
src/main.c
@@ -43,6 +43,7 @@ int main(int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
printff("\n================================ FileSync ===================================\n");
|
||||
if (!strcmp(argv[1], "info") && argc >= 3) {
|
||||
// Informacion de ficheros
|
||||
int i;
|
||||
@@ -61,7 +62,7 @@ int main(int argc, char *argv[]) {
|
||||
printff("Building FileNode..\n");
|
||||
fileNode = FileNode_Build(argv[2]);
|
||||
tScan = Time_GetTime() - tScan;
|
||||
printff("tScan: %9lldus\n", tScan);
|
||||
printff("\ttScan :"); PrintElapsedTime(tScan); printff("\n");
|
||||
FileNode_Save(fileNode, argv[3]);
|
||||
}
|
||||
else if (!strcmp(argv[1], "rescan") && argc == 4) {
|
||||
@@ -74,7 +75,7 @@ int main(int argc, char *argv[]) {
|
||||
long long tScan = Time_GetTime();
|
||||
fileNode = FileNode_Refresh(fileNode, argv[2]);
|
||||
tScan = Time_GetTime() - tScan;
|
||||
printff("tScan: %9lldus\n", tScan);
|
||||
printff("\ttScan :"); PrintElapsedTime(tScan); printff("\n");
|
||||
FileNode_Save(fileNode, argv[3]);
|
||||
}
|
||||
else {
|
||||
@@ -82,7 +83,7 @@ int main(int argc, char *argv[]) {
|
||||
long long tScan = Time_GetTime();
|
||||
fileNode = FileNode_Build(argv[2]);
|
||||
tScan = Time_GetTime() - tScan;
|
||||
printff("tScan: %9lldus\n", tScan);
|
||||
printff("\ttScan :"); PrintElapsedTime(tScan); printff("\n");
|
||||
FileNode_Save(fileNode, argv[3]);
|
||||
}
|
||||
}
|
||||
@@ -163,7 +164,7 @@ FileNode CheckDir(char *path, int recheck) {
|
||||
fileNode = FileNode_Build(path);
|
||||
}
|
||||
tScan = Time_GetTime() - tScan;
|
||||
printff("tScan: %9lldus\n", tScan);
|
||||
printff("\ttScan :"); PrintElapsedTime(tScan); printff("\n");
|
||||
FileNode_Save(fileNode, dirNodesFile);
|
||||
}
|
||||
else {
|
||||
@@ -181,11 +182,16 @@ void PrintStatistics(ActionFileNode actionFileNode) {
|
||||
ActionQueueStatistics statistics;
|
||||
ActionFileNode_Statistics(actionFileNode, &statistics);
|
||||
printff("Statistics\n");
|
||||
printff(" % 12s % 12s % 12s\n", "Read", "Write", "Delete");
|
||||
printff("Left : % 12lld % 12lld % 12lld\n", statistics.readLeft,
|
||||
statistics.writeLeft, statistics.deleteLeft);
|
||||
printff("Right: % 12lld % 12lld % 12lld\n", statistics.readRight,
|
||||
statistics.writeRight, statistics.deleteRight);
|
||||
//printff(" % 12s % 12s % 12s\n", "Read", "Write", "Delete");
|
||||
//printff("Left : % 12lld % 12lld % 12lld\n", statistics.readLeft,
|
||||
// statistics.writeLeft, statistics.deleteLeft);
|
||||
//printff("Right: % 12lld % 12lld % 12lld\n", statistics.readRight,
|
||||
// statistics.writeRight, statistics.deleteRight);
|
||||
|
||||
printff(" % 8s % 8s % 8s\n", "Read", "Write", "Delete");
|
||||
printff("Left :"); PrintDataSize(statistics.readLeft); PrintDataSize(statistics.writeLeft); PrintDataSize(statistics.deleteLeft); printff("\n");
|
||||
printff("Right:"); PrintDataSize(statistics.readRight); PrintDataSize(statistics.writeRight); PrintDataSize(statistics.deleteRight); printff("\n");
|
||||
|
||||
printff("\n");
|
||||
printff("Copy count : % 10d\n", statistics.fullCopyCount);
|
||||
printff("Date copy count: % 10d\n", statistics.dateCopyCount);
|
||||
@@ -221,7 +227,7 @@ int Sync(char *pathLeft, char *pathRight, int recheck, int dryRun) {
|
||||
ActionFileNode actionFileNode = NULL;
|
||||
actionFileNode = ActionFileNode_BuildSync(fileNodeLeft, fileNodeRight);
|
||||
tBuild = Time_GetTime() - tBuild;
|
||||
printff("tBuild: %9lldus\n", tBuild);
|
||||
printff("\ttBuild:"); PrintElapsedTime(tBuild); printff("\n");
|
||||
|
||||
if (dryRun) {
|
||||
// Show action list
|
||||
@@ -267,7 +273,7 @@ int Copy(char *pathLeft, char *pathRight, int reCheck, int dryRun) {
|
||||
ActionFileNode actionFileNode = NULL;
|
||||
actionFileNode = ActionFileNode_BuildCopy(fileNodeLeft, fileNodeRight);
|
||||
tBuild = Time_GetTime() - tBuild;
|
||||
printff("tBuild: %9lldus\n", tBuild);
|
||||
printff("\ttBuild:"); PrintElapsedTime(tBuild); printff("\n");
|
||||
|
||||
if (dryRun) {
|
||||
// Show action list
|
||||
|
||||
47
src/util.c
47
src/util.c
@@ -89,6 +89,53 @@ long long Time_GetCurrentTime() {
|
||||
return (long long)t;
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// PrintElapsedTime
|
||||
//
|
||||
// Prints the elapsed time (input in microseconds (us))
|
||||
int PrintElapsedTime(long long time) {
|
||||
if (time < 1000) {
|
||||
return printff("%8lld us", time);
|
||||
}
|
||||
double msTime = (double)time / 1000;
|
||||
if (msTime < 1000) {
|
||||
return printff("% 8.3f ms", msTime);
|
||||
}
|
||||
double seconds = msTime / 1000;
|
||||
if (seconds < 60) {
|
||||
return printff("% 8.3f s", seconds);
|
||||
}
|
||||
int minutes = (int)seconds / 60;
|
||||
seconds = seconds - (minutes * 60);
|
||||
int hours = minutes / 60;
|
||||
minutes = minutes % 60;
|
||||
return printff("%02d:%02d:%06.3f", hours, minutes, seconds);
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// PrintDataSize
|
||||
//
|
||||
// Prints the data size (input in bytes)
|
||||
int PrintDataSize(long long size) {
|
||||
if (size < 1024) {
|
||||
return printff("%8lld B ", size);
|
||||
}
|
||||
double kibSize = (double)size / 1024;
|
||||
if (kibSize < 1024) {
|
||||
return printff("% 8.3f KiB", kibSize);
|
||||
}
|
||||
double mibSize = kibSize / 1024;
|
||||
if (mibSize < 1024) {
|
||||
return printff("% 8.3f MiB", mibSize);
|
||||
}
|
||||
double gibSize = mibSize / 1024;
|
||||
if (gibSize < 1024) {
|
||||
return printff("% 8.3f GiB", gibSize);
|
||||
}
|
||||
double tibSize = gibSize / 1024;
|
||||
return printff("% 8.3f TiB", tibSize);
|
||||
}
|
||||
|
||||
int printff(char *fmt, ...) {
|
||||
va_list ap;
|
||||
int n;
|
||||
|
||||
12
src/util.h
12
src/util.h
@@ -25,6 +25,18 @@ void Time_Pause(int pausa);
|
||||
// Gets the current time in POSIX.
|
||||
long long Time_GetCurrentTime();
|
||||
|
||||
/////////////////////////////
|
||||
// PrintElapsedTime
|
||||
//
|
||||
// Prints the elapsed time (input in microseconds (us))
|
||||
int PrintElapsedTime(long long time);
|
||||
|
||||
/////////////////////////////
|
||||
// PrintDataSize
|
||||
//
|
||||
// Prints the data size (input in bytes)
|
||||
int PrintDataSize(long long size);
|
||||
|
||||
int printff(char *fmt, ...);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user