Skip to content

Commit

Permalink
refactor the function of StatsEq
Browse files Browse the repository at this point in the history
  • Loading branch information
carmark committed Jan 9, 2016
1 parent 23496fd commit 5b7a2fb
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions storage/influxdb/influxdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,9 @@ func (self *influxDbTestStorageDriver) StatsEq(a, b *info.ContainerStats) bool {
return false
}
// Check only the stats populated in influxdb.
if a.Cpu.Usage.Total != b.Cpu.Usage.Total {
if !reflect.DeepEqual(a.Cpu.Usage, b.Cpu.Usage) {
return false
}
if a.Cpu.Usage.System != b.Cpu.Usage.System {
return false
}
if a.Cpu.Usage.User != b.Cpu.Usage.User {
return false
}

// TODO simpler way to check if arrays are equal?
if a.Cpu.Usage.PerCpu == nil && b.Cpu.Usage.PerCpu != nil {
return false
}
if a.Cpu.Usage.PerCpu != nil && b.Cpu.Usage.PerCpu == nil {
return false
}
if len(a.Cpu.Usage.PerCpu) != len(b.Cpu.Usage.PerCpu) {
return false
}
for i, usage := range a.Cpu.Usage.PerCpu {
if usage != b.Cpu.Usage.PerCpu[i] {
return false
}
}

if a.Memory.Usage != b.Memory.Usage {
return false
Expand Down

0 comments on commit 5b7a2fb

Please sign in to comment.