⚡ Improving performance.#2
Conversation
Pull Request Test Coverage Report for Build 17
💛 - Coveralls |
|
I read the test coverage report and was confused as to why test coverage had declined. |
| for i := 0; i < len(items); i++ { | ||
| w := items[i] | ||
|
|
||
| if w == nil { |
There was a problem hiding this comment.
Because the parameters call into the method nextSmoothWeighted() always is greater than 1. Another way, whether it is len(items) =0; i !< 0; len(items) > 1 , items[i] != nil; So, those code never gets executed.
|
|
||
| // Next returns next selected server. | ||
| func (w *SW) Next() interface{} { | ||
| i := w.nextWeighted() |
There was a problem hiding this comment.
if w.n == 0; just return; No additional method calls are required.
| } | ||
|
|
||
| // nextWeighted returns next selected weighted object. | ||
| func (w *SW) nextWeighted() *smoothWeighted { |
There was a problem hiding this comment.
It would be more concise to make these judgments in next.
|
All tests are passed. Please reviews. |
|
OK.Cover more tests.Please reviews. |
roundrobin_weighted.go
Outdated
| if w.cw == 0 { | ||
| return nil | ||
| } | ||
| // When does this happen? |
There was a problem hiding this comment.
see http://kb.linuxvirtualserver.org/wiki/Weighted_Round-Robin_Scheduling, the clang implementation.
There was a problem hiding this comment.
I has create a issue talk about those code. #3
but now, revert that code in this commit.
|
|
||
| // Next returns next selected server. | ||
| func (w *SW) Next() interface{} { | ||
| i := w.nextWeighted() |
There was a problem hiding this comment.
because can be return nextSmoothWeighted(w.items).Item
look blow:
// Next returns next selected server.
func (w *SW) Next() interface{} {
switch w.n {
case 0:
return nil
case 1:
return w.items[0].Item
default:
return nextSmoothWeighted(w.items).Item
}
}
|
Please reviews! |
Improving of method gcb(). Adding tests for the method.Please reviews.