mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Improved poor memory efficiency of awslogs
Signed-off-by: YAMASAKI Masahide <masahide.y@gmail.com>
This commit is contained in:
parent
23e857cd3d
commit
524f306340
2 changed files with 20 additions and 3 deletions
|
@ -590,9 +590,9 @@ func (slice byTimestamp) Swap(i, j int) {
|
|||
}
|
||||
|
||||
func unwrapEvents(events []wrappedEvent) []*cloudwatchlogs.InputLogEvent {
|
||||
cwEvents := []*cloudwatchlogs.InputLogEvent{}
|
||||
for _, input := range events {
|
||||
cwEvents = append(cwEvents, input.inputLogEvent)
|
||||
cwEvents := make([]*cloudwatchlogs.InputLogEvent, len(events))
|
||||
for i, input := range events {
|
||||
cwEvents[i] = input.inputLogEvent
|
||||
}
|
||||
return cwEvents
|
||||
}
|
||||
|
|
|
@ -1034,3 +1034,20 @@ func TestCreateTagSuccess(t *testing.T) {
|
|||
t.Errorf("Expected LogStreamName to be %s", "test-container/container-abcdefghijklmnopqrstuvwxyz01234567890")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkUnwrapEvents(b *testing.B) {
|
||||
events := make([]wrappedEvent, maximumLogEventsPerPut)
|
||||
for i := 0; i < maximumLogEventsPerPut; i++ {
|
||||
mes := strings.Repeat("0", maximumBytesPerEvent)
|
||||
events[i].inputLogEvent = &cloudwatchlogs.InputLogEvent{
|
||||
Message: &mes,
|
||||
}
|
||||
}
|
||||
|
||||
as := assert.New(b)
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
res := unwrapEvents(events)
|
||||
as.Len(res, maximumLogEventsPerPut)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue