mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 10:58:57 +00:00
test: Mend the transfer benchmark
This commit is contained in:
parent
c0ab669142
commit
2fdf9bc55d
@ -88,6 +88,8 @@ func benchmarkTransfer(t *testing.T, files, sizeExp int) {
|
|||||||
|
|
||||||
var t0, t1 time.Time
|
var t0, t1 time.Time
|
||||||
lastEvent := 0
|
lastEvent := 0
|
||||||
|
oneItemFinished := false
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
for {
|
for {
|
||||||
evs, err := receiver.Events(lastEvent)
|
evs, err := receiver.Events(lastEvent)
|
||||||
@ -99,22 +101,34 @@ loop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, ev := range evs {
|
for _, ev := range evs {
|
||||||
if ev.Type == "StateChanged" {
|
lastEvent = ev.ID
|
||||||
|
|
||||||
|
switch ev.Type {
|
||||||
|
case "ItemFinished":
|
||||||
|
oneItemFinished = true
|
||||||
|
continue
|
||||||
|
|
||||||
|
case "StateChanged":
|
||||||
data := ev.Data.(map[string]interface{})
|
data := ev.Data.(map[string]interface{})
|
||||||
if data["folder"].(string) != "default" {
|
if data["folder"].(string) != "default" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Println(ev)
|
|
||||||
if data["to"].(string) == "syncing" {
|
switch data["to"].(string) {
|
||||||
|
case "syncing":
|
||||||
t0 = ev.Time
|
t0 = ev.Time
|
||||||
continue
|
continue
|
||||||
}
|
|
||||||
if !t0.IsZero() && data["to"].(string) == "idle" {
|
case "idle":
|
||||||
t1 = ev.Time
|
if !oneItemFinished {
|
||||||
break loop
|
continue
|
||||||
|
}
|
||||||
|
if !t0.IsZero() {
|
||||||
|
t1 = ev.Time
|
||||||
|
break loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastEvent = ev.ID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
|
@ -453,7 +453,10 @@ func startWalker(dir string, res chan<- fileInfo, abort <-chan struct{}) chan er
|
|||||||
f = fileInfo{
|
f = fileInfo{
|
||||||
name: rn,
|
name: rn,
|
||||||
mode: info.Mode(),
|
mode: info.Mode(),
|
||||||
mod: info.ModTime().Truncate(time.Microsecond).UnixNano(),
|
// comparing timestamps with better precision than a second
|
||||||
|
// is problematic as there is rounding and truncatign going
|
||||||
|
// on at every level
|
||||||
|
mod: info.ModTime().Unix(),
|
||||||
size: info.Size(),
|
size: info.Size(),
|
||||||
}
|
}
|
||||||
sum, err := md5file(path)
|
sum, err := md5file(path)
|
||||||
|
Loading…
Reference in New Issue
Block a user