Repository navigation
优化 性能 - #626
Merged
Merged
优化 性能#626
Conversation
unknwon
suggested changes
Jul 22, 2018
| keysLatitude []string | ||
| keysLongitude []string | ||
| keysDistrictCode []string | ||
| stats StatsInfo |
Contributor
There was a problem hiding this comment.
这部分为了性能的字段建议单独放一起(空行分隔),然后加个注释简单说一下方便以后维护的人
| Key: "ip", | ||
| DataPath: "./test_data/17monipdb.dat", | ||
| } | ||
| ipt.Init() |
Contributor
There was a problem hiding this comment.
assert.Nil(t, ipt.Init())
下同
| //}, | ||
| //{ | ||
| // "ip2": "183.251.28.250", | ||
| //}, |
Contributor
There was a problem hiding this comment.
这里注释掉的如果是不用的话,直接删了吧,后来的维护会很迷惑又不敢乱动
| // 2. 首字符为非法字符时,去掉首字符(例如,如果字符串全为非法字符,则转换后为空) | ||
| // 3. 非首字符并且为非法字符时,使用 "_" 替代非法字符 | ||
| func PandoraKey(key string) (string, bool) { | ||
| func CheckPandoraKey(key string) bool { |
| } | ||
|
|
||
| /* | ||
| //1000000 1584 ns/op 32 B/op 2 allocs/op |
Contributor
There was a problem hiding this comment.
留个注释,就说如果确认新版有性能和内存上的优化的话,就可以删掉了。或者 git 本来就有历史,直接删了也能找回的
| func BenchmarkCheckPandoraKey(b *testing.B) { | ||
| b.ReportAllocs() | ||
| testKeys := []string{"@timestamp", ".dot", "percent%100", "^^^^^^^^^^", "timestamp", "aaa"} | ||
| //testKeys := []string{"timestamp", "aaa"} |
| }, | ||
| { | ||
| "timestamp": "2018-07-18T10:17:36.549054846+08:00", | ||
| //"timestamp": "2018-07-19T10:17:36.549054846+08:00", |
| }, | ||
| { | ||
| "timestamp": "2018-07-18T10:17:36.549054846+08:00", | ||
| //"timestamp": "2018-07-19T10:17:36.549054846+08:00", |
| }, | ||
| { | ||
| "timestamp": "2018-07-18T10:17:36.549054846+08:00", | ||
| //"timestamp": "2018-07-19T10:17:36.549054846+08:00", |
| } | ||
| if valid { | ||
| return key, true | ||
| return []byte(key), true |
Contributor
There was a problem hiding this comment.
来回转换 bytes 到 string 从逻辑上来讲其实反而多分配了一次 []byte 吧?上层也是仍旧要转回 string 类型而不能直接使用 []byte
unknwon
reviewed
Jul 23, 2018
| writeLimit, _ := conf.GetIntOr(KeyFtWriteLimit, defaultWriteLimit) | ||
| strategy, _ := conf.GetStringOr(KeyFtStrategy, KeyFtStrategyBackupOnly) | ||
| longDataDiscard, _ := conf.GetBoolOr(KeyFtLongDataDiscard, false) | ||
| sendType, _ := conf.GetStringOr(KeySenderType, "") //此处不会没有SenderType,在调用NewFtSender时已经检查 |
| memoryChannel: memoryChannel, | ||
| memoryChannelSize: memoryChannelSize, | ||
| longDataDiscard: longDataDiscard, | ||
| innerSendType: sendType, |
Contributor
There was a problem hiding this comment.
s/innerSendType/innerSenderType/
Contributor
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes [issue number]
Changes
Reviewers
Wiki Changes
Checklist