From 947e08e4f9e3c9c44b346adff4eb6d68fa79a726 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 26 Jun 2025 22:19:22 +0300 Subject: Refactor profiling and benchmarking tools from bash to Go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- cmd/dtail-tools/main.go | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 cmd/dtail-tools/main.go (limited to 'cmd') 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 [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 -h' for command-specific help") +} \ No newline at end of file -- cgit v1.2.3