Skip to content

Commit a1ba9f1

Browse files
committed
..
1 parent 779914b commit a1ba9f1

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

main.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ package main
55
import (
66
"file-compressor/compressor"
77
"file-compressor/utils"
8+
89
"time"
9-
"fmt"
1010
)
1111

1212

@@ -30,7 +30,6 @@ func main() {
3030
utils.ColorPrint(utils.RED, err.Error() + "\n")
3131
} else {
3232
endTime := time.Now()
33-
tookTime := endTime.Sub(startTime).Microseconds()
34-
utils.ColorPrint(utils.GREEN, fmt.Sprintf("Took %d ms\n", tookTime))
33+
utils.ColorPrint(utils.GREEN, "Time taken: " + utils.TimeTrack(startTime, endTime) + "\n")
3534
}
3635
}

resources.rc

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
IDI_ICON1 ICON "icon.ico"
44

55
1 VERSIONINFO
6-
FILEVERSION 1,0,2
7-
PRODUCTVERSION 1,0,2
6+
FILEVERSION 1,0,3
7+
PRODUCTVERSION 1,0,3
88
FILEOS 0x4
99
FILETYPE 0x1
1010
{
@@ -14,12 +14,12 @@ FILETYPE 0x1
1414
{
1515
VALUE "CompanyName", "BrainbirdLab"
1616
VALUE "FileDescription", "File Compress-Encryption program"
17-
VALUE "FileVersion", "1.0.2"
17+
VALUE "FileVersion", "1.0.3"
1818
VALUE "InternalName", "piarch"
1919
VALUE "LegalCopyright", "BrainbirdLab"
2020
VALUE "OriginalFilename", "piarch"
2121
VALUE "ProductName", "piarch"
22-
VALUE "ProductVersion", "1.0.2"
22+
VALUE "ProductVersion", "1.0.3"
2323
VALUE "Author", "Fuad Hasan"
2424
}
2525
}

resources.syso

0 Bytes
Binary file not shown.

test_zip/compressed.bin

1 Byte
Binary file not shown.

utils/helper.go

+27
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package utils
22

33
import (
44
"fmt"
5+
"time"
56
)
67

78
type File struct {
@@ -39,3 +40,29 @@ func FileSize(sizeBytes int64) string {
3940
return fmt.Sprintf("%.1f %cB",
4041
float64(sizeBytes)/float64(div), "KMGTPE"[exp])
4142
}
43+
44+
func TimeTrack(startTime, endTime time.Time) string {
45+
elapsedTime := endTime.Sub(startTime)
46+
//return nanoseconds, microseconds, milliseconds, seconds, minutes, hours
47+
if elapsedTime < 1000 {
48+
return fmt.Sprintf("%d ns", elapsedTime)
49+
}
50+
51+
if elapsedTime < 1000000 {
52+
return fmt.Sprintf("%d µs", elapsedTime/1000)
53+
}
54+
55+
if elapsedTime < 1000000000 {
56+
return fmt.Sprintf("%d ms", elapsedTime/1000000)
57+
}
58+
59+
if elapsedTime < 60000000000 {
60+
return fmt.Sprintf("%d s", elapsedTime/1000000000)
61+
}
62+
63+
if elapsedTime < 3600000000000 {
64+
return fmt.Sprintf("%d m", elapsedTime/60000000000)
65+
}
66+
67+
return fmt.Sprintf("%d h", elapsedTime/3600000000000)
68+
}

0 commit comments

Comments
 (0)