-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tmc): remove LogSyncer line length limit. (#1187)
## Reasons for the changes The first implementation of the LogSyncer had a line length limit which amounted to the size of the scanner buffer. ### Description of changes A custom implementation of `readLines()` was implemented without any line length limit (other than available memory). Signed-off-by: Tiago Natel <t.nateldemoura@gmail.com>
- Loading branch information
Showing
4 changed files
with
153 additions
and
70 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2023 Terramate GmbH | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package cloud | ||
|
||
import ( | ||
"bytes" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
const nlines = 10000 | ||
|
||
func BenchmarkCloudReadLines(b *testing.B) { | ||
b.ReportAllocs() | ||
b.StopTimer() | ||
var bufData string | ||
for i := 0; i < nlines; i++ { | ||
bufData += strings.Repeat("A", 80) + "\n" | ||
} | ||
b.StartTimer() | ||
for i := 0; i < b.N; i++ { | ||
buf := bytes.NewBufferString(bufData) | ||
var pending []byte | ||
for { | ||
_, rest, err := readLines(buf, pending[:]) | ||
if err != nil { | ||
break | ||
} | ||
pending = rest | ||
} | ||
} | ||
} | ||
|
||
func BenchmarkCloudReadLine(b *testing.B) { | ||
b.ReportAllocs() | ||
b.StopTimer() | ||
var bufData string | ||
for i := 0; i < nlines; i++ { | ||
bufData += strings.Repeat("A", 80) + "\n" | ||
} | ||
b.StartTimer() | ||
for i := 0; i < b.N; i++ { | ||
buf := bytes.NewBufferString(bufData) | ||
for { | ||
_, err := readLine(buf) | ||
if err != nil { | ||
break | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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