diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-26 22:19:22 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-26 22:19:22 +0300 |
| commit | 947e08e4f9e3c9c44b346adff4eb6d68fa79a726 (patch) | |
| tree | cfa94aba72f91d26657de09b7a5b6a23eff10fd7 /cmd | |
| parent | 1e643ac66765fc0ab4224335191731d8b77fece2 (diff) | |
Refactor profiling and benchmarking tools from bash to Go
This major refactoring replaces all bash-based profiling and benchmarking
scripts with a unified Go tool (dtail-tools) that provides:
- Better cross-platform compatibility
- Improved error handling and reliability
- Structured data generation for test files
- Consistent command-line interface
- Easier maintenance and extensibility
Key changes:
- Created dtail-tools command with profile and benchmark subcommands
- Implemented common utilities for data generation and file operations
- Updated Makefile to use the new Go-based tools
- Maintained backward compatibility with existing make targets
- Fixed ParseSize to handle single-letter suffixes (10M, 1G, etc.)
The new tool supports all previous functionality:
- profile-quick, profile-all, profile-dmap
- benchmark creation, comparison, and management
- Test data generation with multiple formats
- Profile analysis and listing
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/dtail-tools/main.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/cmd/dtail-tools/main.go b/cmd/dtail-tools/main.go new file mode 100644 index 0000000..591ed4b --- /dev/null +++ b/cmd/dtail-tools/main.go @@ -0,0 +1,53 @@ +package main + +import ( + "fmt" + "os" + + "github.com/mimecast/dtail/internal/tools/benchmark" + "github.com/mimecast/dtail/internal/tools/profile" +) + +func main() { + if len(os.Args) < 2 { + printUsage() + os.Exit(1) + } + + command := os.Args[1] + + // Remove command from args for subcommand parsing + os.Args = append([]string{os.Args[0]}, os.Args[2:]...) + + switch command { + case "profile": + if err := profile.Run(); err != nil { + fmt.Fprintf(os.Stderr, "Error: %v\n", err) + os.Exit(1) + } + case "benchmark": + if err := benchmark.Run(); err != nil { + fmt.Fprintf(os.Stderr, "Error: %v\n", err) + os.Exit(1) + } + case "help", "-h", "--help": + printUsage() + default: + fmt.Fprintf(os.Stderr, "Unknown command: %s\n", command) + printUsage() + os.Exit(1) + } +} + +func printUsage() { + fmt.Println("dtail-tools - DTail performance analysis toolkit") + fmt.Println() + fmt.Println("Usage: dtail-tools <command> [options]") + fmt.Println() + fmt.Println("Commands:") + fmt.Println(" profile Run profiling on dtail commands") + fmt.Println(" benchmark Run benchmarks and manage baselines") + fmt.Println(" help Show this help message") + fmt.Println() + fmt.Println("Run 'dtail-tools <command> -h' for command-specific help") +}
\ No newline at end of file |
