commit 44fae27244a2442854423c5af2d83b939331ca70
parent 15c9f1a320b6a1ae9cbfea92208469633db715ff
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 30 Jan 2023 23:19:31 -0800
keep track of completed chunks as well as time it took to upload
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/cmd/dkfupload/main.go b/cmd/dkfupload/main.go
@@ -22,6 +22,7 @@ import (
"strconv"
"strings"
"sync"
+ "sync/atomic"
"time"
)
@@ -32,6 +33,8 @@ const (
torProxyAddr = "127.0.0.1:9050"
)
+var chunksCompleted int64 // atomic
+
func main() {
var nbThreads int
var filedropUUID string
@@ -114,6 +117,7 @@ func main() {
if resp.StatusCode != http.StatusOK {
log.Fatalln(fmt.Errorf("invalid status code %s", resp.Status))
}
+ log.Println("done sending metadata")
}
chunksCh := make(chan int64)
@@ -144,6 +148,7 @@ func work(i int, wg *sync.WaitGroup, chunksCh chan int64, isLocal, dry bool, max
buf := make([]byte, maxChunkSize)
for chunkNum := range chunksCh {
+ start := time.Now()
offset := chunkNum * maxChunkSize
n, _ := f.ReadAt(buf, offset)
log.Printf("Thread #%03d | chunk #%03d | read %d | from %d to %d\n", i, chunkNum, n, offset, offset+int64(n))
@@ -180,6 +185,8 @@ func work(i int, wg *sync.WaitGroup, chunksCh chan int64, isLocal, dry bool, max
return nil
})
}
+ newChunksCompleted := atomic.AddInt64(&chunksCompleted, 1)
+ log.Printf("Thread #%03d | chunk #%03d | completed in %s (%d/%d)\n", i, chunkNum, time.Since(start), newChunksCompleted, nbChunks)
}
wg.Done()
}