-
Notifications
You must be signed in to change notification settings - Fork 135
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
Update logger_benchmark_test.go #2109
base: main
Are you sure you want to change the base?
Conversation
Title corrections Follow tests in more detail Signed-off-by: CKAARRAA <[email protected]>
WalkthroughThe changes in this pull request focus on two files: Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Outside diff range comments (1)
testing/benchmarks/logger_benchmark_test.go (1)
Line range hint
165-169
: Consider adding buffer cleanup to prevent memory growth.The current implementation uses a single
bytes.Buffer
for the entire benchmark run. Consider resetting or creating a new buffer periodically to prevent unbounded memory growth during benchmarking.Here's a suggested improvement:
func newPhusluLogger() *phuslu.Logger { - cfg := phuslu.DefaultConfig() // dummy config - l := phuslu.NewLogger( - &bytes.Buffer{}, &cfg) - return l + cfg := phuslu.DefaultConfig() + buf := &bytes.Buffer{} + l := phuslu.NewLogger(buf, &cfg) + // Add method to access buffer for cleanup + return l.WithContext("buffer", buf) } +// Add to benchmark functions after b.ResetTimer(): +// if n > 0 && n%1000 == 0 { +// if buf, ok := logger.Context().Value("buffer").(*bytes.Buffer); ok { +// buf.Reset() +// } +// }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- testing/benchmarks/logger_benchmark_test.go (6 hunks)
🔇 Additional comments (1)
testing/benchmarks/logger_benchmark_test.go (1)
Line range hint
31-162
: LGTM! Well-structured and comprehensive benchmarks.The benchmark patterns are consistent across all log levels and styles, providing good coverage of different logging scenarios. The structure is clean and follows best practices for Go benchmarks.
/* -------------------------------------------------------------------------- */ | ||
|
||
// Benchmark function for phuslu logger with pretty style. | ||
func BenchmarkPhusluLoggerPrettyInfo(b *testing.B) { | ||
b.SetBytes(1) // every operation is 1 log message |
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.
🛠️ Refactor suggestion
Apply b.SetBytes(1)
consistently across all benchmark functions.
Good addition for clarifying that each operation represents one log message. However, this should be applied consistently across all benchmark functions to ensure accurate throughput measurements.
Add the same line to all benchmark functions:
func BenchmarkPhusluLoggerJSONInfo(b *testing.B) {
+ b.SetBytes(1) // every operation is 1 log message
logger := newPhusluLogger().WithConfig(configWithJSON("info"))
Committable suggestion was skipped due to low confidence.
Signed-off-by: CKAARRAA <[email protected]>
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- beacond/cmd/main.go (2 hunks)
🔇 Additional comments (3)
beacond/cmd/main.go (3)
37-42
: LGTM! Good use of constants for configuration values.The introduction of these constants improves maintainability by centralizing these configuration values and follows Go best practices.
63-63
: LGTM! Proper usage of the newly defined constants.The constants are correctly used to replace the hardcoded strings, maintaining consistency throughout the codebase.
Also applies to: 67-67
37-42
: Verify uniqueness of constant definitions.Let's ensure these constants aren't defined elsewhere in the codebase to avoid potential conflicts.
✅ Verification successful
Constants are uniquely defined
The constants
DefaultNodeName
andDefaultNodeDescription
are only defined once in the codebase, specifically inbeacond/cmd/main.go
. There are no duplicate definitions that could cause conflicts.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any other definitions of these constants echo "Searching for DefaultNodeName definitions:" rg "DefaultNodeName\s*=\s*" --type go echo -e "\nSearching for DefaultNodeDescription definitions:" rg "DefaultNodeDescription\s*=\s*" --type goLength of output: 445
// TODO(#issue-number): Remove these components and implement proper | ||
// configuration and chain specification loading from the built node |
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.
🧹 Nitpick (assertive)
Replace #issue-number
placeholder with an actual issue number.
The TODO comment provides clear next steps but lacks proper issue tracking. This could lead to the task being overlooked.
Would you like me to help create a GitHub issue to track this TODO item? This would help ensure proper follow-up on the configuration and chain specification implementation task.
/* -------------------------------------------------------------------------- */ | ||
/* Warn */ | ||
/* Warn */ | ||
/* -------------------------------------------------------------------------- */ |
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.
Thanks! Why all these comments are changed ?
Title corrections
Follow tests in more detail
Summary by CodeRabbit