mirror of
https://github.com/golang/go
synced 2024-11-18 05:24:47 -07:00
internal/trace: change Less to make sorting events deterministice
The existing code just used timestamps. The new code uses more fields when timestamps are equal. Revised to shorten code per reviewer comments. Change-Id: Ibd0824d0acd7644484d536b1a754a0da156fac3d Reviewed-on: https://go-review.googlesource.com/113721 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
parent
ef880a2f61
commit
1764609b8b
@ -133,7 +133,7 @@ func order1007(m map[int][]*Event) (events []*Event, err error) {
|
|||||||
ev.Ts = ts
|
ev.Ts = ts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sort.Stable(eventList(events))
|
sort.Sort(eventList(events))
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -243,7 +243,20 @@ func (l orderEventList) Len() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l orderEventList) Less(i, j int) bool {
|
func (l orderEventList) Less(i, j int) bool {
|
||||||
return l[i].ev.Ts < l[j].ev.Ts
|
a, b := l[i].ev, l[j].ev
|
||||||
|
if a.Ts != b.Ts {
|
||||||
|
return a.Ts < b.Ts
|
||||||
|
}
|
||||||
|
if a.Type != b.Type {
|
||||||
|
return a.Type < b.Type
|
||||||
|
}
|
||||||
|
if a.P != b.P {
|
||||||
|
return a.P < b.P
|
||||||
|
}
|
||||||
|
if a.G != b.G {
|
||||||
|
return a.G < b.G
|
||||||
|
}
|
||||||
|
return a.Args[0] < b.Args[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l orderEventList) Swap(i, j int) {
|
func (l orderEventList) Swap(i, j int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user