Show upload rate and speed
This commit is contained in:
parent
13589535a8
commit
d2d7843b6f
9
dau.go
9
dau.go
@ -16,7 +16,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
var current_version = "0.3"
|
var current_version = "0.4"
|
||||||
|
|
||||||
var last_check = time.Now()
|
var last_check = time.Now()
|
||||||
var new_last_check = time.Now()
|
var new_last_check = time.Now()
|
||||||
@ -180,6 +180,7 @@ func process_file(file string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
start := time.Now()
|
||||||
client := &http.Client{ Timeout: time.Second * 30 }
|
client := &http.Client{ Timeout: time.Second * 30 }
|
||||||
resp, err := client.Do(request)
|
resp, err := client.Do(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -212,7 +213,11 @@ func process_file(file string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var a = res.Attachments[0]
|
var a = res.Attachments[0]
|
||||||
log.Printf("Uploaded to %s %dx%d, %d bytes\n", a.Url, a.Width, a.Height, a.Size)
|
elapsed := time.Since(start)
|
||||||
|
rate := float64(a.Size) / elapsed.Seconds() / 1024.0
|
||||||
|
|
||||||
|
log.Printf("Uploaded to %s %dx%d", a.Url, a.Width, a.Height)
|
||||||
|
log.Printf("%d bytes transferred in %.2f seconds (%.2f KiB/s)", a.Size, elapsed.Seconds(), rate)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user