Skip to content

Commit

Permalink
Use pure RMS to compute unbalance
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlo Alberto Ferraris committed Nov 14, 2017
1 parent c4fe3a5 commit 917a869
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,17 @@ func getBL(loads map[BrokerID]float64) []brokerLoad {

func getUnbalanceBL(brokers []brokerLoad) float64 {
var sumBrokerLoad float64
var maxBrokerLoad float64

for _, broker := range brokers {
sumBrokerLoad += broker.Load
if maxBrokerLoad < broker.Load {
maxBrokerLoad = broker.Load
}
}

avgBrokerLoad := sumBrokerLoad / float64(len(brokers))

var brokerUnbalance float64
for _, broker := range brokers {
relBrokerLoad := broker.Load/avgBrokerLoad - 1.0
if relBrokerLoad > 0 {
brokerUnbalance += relBrokerLoad * relBrokerLoad
} else {
brokerUnbalance += relBrokerLoad * relBrokerLoad / 2
}
brokerUnbalance += relBrokerLoad * relBrokerLoad
}

return brokerUnbalance
Expand Down

0 comments on commit 917a869

Please sign in to comment.