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
|
||||
lastEvent := 0
|
||||
oneItemFinished := false
|
||||
|
||||
loop:
|
||||
for {
|
||||
evs, err := receiver.Events(lastEvent)
|
||||
@ -99,22 +101,34 @@ loop:
|
||||
}
|
||||
|
||||
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{})
|
||||
if data["folder"].(string) != "default" {
|
||||
continue
|
||||
}
|
||||
log.Println(ev)
|
||||
if data["to"].(string) == "syncing" {
|
||||
|
||||
switch data["to"].(string) {
|
||||
case "syncing":
|
||||
t0 = ev.Time
|
||||
continue
|
||||
}
|
||||
if !t0.IsZero() && data["to"].(string) == "idle" {
|
||||
t1 = ev.Time
|
||||
break loop
|
||||
|
||||
case "idle":
|
||||
if !oneItemFinished {
|
||||
continue
|
||||
}
|
||||
if !t0.IsZero() {
|
||||
t1 = ev.Time
|
||||
break loop
|
||||
}
|
||||
}
|
||||
}
|
||||
lastEvent = ev.ID
|
||||
}
|
||||
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
|
@ -453,7 +453,10 @@ func startWalker(dir string, res chan<- fileInfo, abort <-chan struct{}) chan er
|
||||
f = fileInfo{
|
||||
name: rn,
|
||||
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(),
|
||||
}
|
||||
sum, err := md5file(path)
|
||||
|
Loading…
Reference in New Issue
Block a user