-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
⚡ Improving performance. #2
base: master
Are you sure you want to change the base?
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. |
@@ -92,10 +83,6 @@ func nextSmoothWeighted(items []*smoothWeighted) (best *smoothWeighted) { | |||
for i := 0; i < len(items); i++ { | |||
w := items[i] | |||
|
|||
if w == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -66,23 +66,14 @@ func (w *SW) All() map[interface{}]int { | |||
|
|||
// Next returns next selected server. | |||
func (w *SW) Next() interface{} { | |||
i := w.nextWeighted() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see http://kb.linuxvirtualserver.org/wiki/Weighted_Round-Robin_Scheduling, the clang implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I has create a issue talk about those code. #3
but now, revert that code in this commit.
@@ -66,23 +66,14 @@ func (w *SW) All() map[interface{}]int { | |||
|
|||
// Next returns next selected server. | |||
func (w *SW) Next() interface{} { | |||
i := w.nextWeighted() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why removed this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.