diff --git a/cli/api.go b/cli/api.go index d7fdfdc..6e649c0 100644 --- a/cli/api.go +++ b/cli/api.go @@ -5,13 +5,13 @@ import ( "fmt" "log/slog" - "github.com/AlexsanderHamir/prof/args" - "github.com/AlexsanderHamir/prof/benchmark" - "github.com/AlexsanderHamir/prof/collector" - "github.com/AlexsanderHamir/prof/config" - "github.com/AlexsanderHamir/prof/shared" - "github.com/AlexsanderHamir/prof/tracker" - "github.com/AlexsanderHamir/prof/version" + "github.com/AlexsanderHamir/prof/engine/benchmark" + "github.com/AlexsanderHamir/prof/engine/collector" + "github.com/AlexsanderHamir/prof/engine/tracker" + "github.com/AlexsanderHamir/prof/internal/args" + "github.com/AlexsanderHamir/prof/internal/config" + "github.com/AlexsanderHamir/prof/internal/shared" + "github.com/AlexsanderHamir/prof/internal/version" "github.com/spf13/cobra" ) diff --git a/cli/helpers.go b/cli/helpers.go index c1e64a5..53b9060 100644 --- a/cli/helpers.go +++ b/cli/helpers.go @@ -6,11 +6,11 @@ import ( "math" "sort" - "github.com/AlexsanderHamir/prof/args" - "github.com/AlexsanderHamir/prof/benchmark" - "github.com/AlexsanderHamir/prof/config" - "github.com/AlexsanderHamir/prof/shared" - "github.com/AlexsanderHamir/prof/tracker" + "github.com/AlexsanderHamir/prof/engine/benchmark" + "github.com/AlexsanderHamir/prof/engine/tracker" + "github.com/AlexsanderHamir/prof/internal/args" + "github.com/AlexsanderHamir/prof/internal/config" + "github.com/AlexsanderHamir/prof/internal/shared" ) func printConfiguration(benchArgs *args.BenchArgs, functionFilterPerBench map[string]config.FunctionFilter) { diff --git a/benchmark/api.go b/engine/benchmark/api.go similarity index 88% rename from benchmark/api.go rename to engine/benchmark/api.go index 6236374..a138e81 100644 --- a/benchmark/api.go +++ b/engine/benchmark/api.go @@ -7,10 +7,10 @@ import ( "os" "path/filepath" - "github.com/AlexsanderHamir/prof/args" - "github.com/AlexsanderHamir/prof/collector" + "github.com/AlexsanderHamir/prof/engine/collector" + "github.com/AlexsanderHamir/prof/internal/args" + "github.com/AlexsanderHamir/prof/internal/shared" "github.com/AlexsanderHamir/prof/parser" - "github.com/AlexsanderHamir/prof/shared" ) // SetupDirectories creates the structure of the library's output. @@ -73,12 +73,12 @@ func ProcessProfiles(benchmarkName string, profiles []string, tag string) error outputFile := filepath.Join(textDir, fmt.Sprintf("%s_%s.%s", benchmarkName, profile, shared.TextExtension)) profileFunctionsDir := filepath.Join(tagDir, profile+shared.FunctionsDirSuffix, benchmarkName) - if err := collector.GenerateProfileTextOutput(profileFile, outputFile); err != nil { + if err := collector.GetProfileTextOutput(profileFile, outputFile); err != nil { return fmt.Errorf("failed to generate text profile for %s: %w", profile, err) } pngDesiredFilePath := filepath.Join(profileFunctionsDir, fmt.Sprintf("%s_%s.png", benchmarkName, profile)) - if err := collector.GeneratePNGVisualization(profileFile, pngDesiredFilePath); err != nil { + if err := collector.GetPNGOutput(profileFile, pngDesiredFilePath); err != nil { return fmt.Errorf("failed to generate PNG visualization for %s: %w", profile, err) } @@ -101,7 +101,7 @@ func CollectProfileFunctions(args *args.CollectionArgs) error { return fmt.Errorf("failed to extract function names: %w", err) } - if err = collector.SaveAllFunctionsPprofContents(functions, paths.ProfileBinaryFile, paths.FunctionDirectory); err != nil { + if err = collector.GetFunctionsOutput(functions, paths.ProfileBinaryFile, paths.FunctionDirectory); err != nil { return fmt.Errorf("getAllFunctionsPprofContents failed: %w", err) } } diff --git a/benchmark/helpers.go b/engine/benchmark/helpers.go similarity index 99% rename from benchmark/helpers.go rename to engine/benchmark/helpers.go index 0705bb0..f1f1edd 100644 --- a/benchmark/helpers.go +++ b/engine/benchmark/helpers.go @@ -10,7 +10,7 @@ import ( "strings" "time" - "github.com/AlexsanderHamir/prof/shared" + "github.com/AlexsanderHamir/prof/internal/shared" ) func getProfileFlags() map[string]string { diff --git a/collector/api.go b/engine/collector/api.go similarity index 81% rename from collector/api.go rename to engine/collector/api.go index 10d83ac..99d6dea 100644 --- a/collector/api.go +++ b/engine/collector/api.go @@ -7,8 +7,8 @@ import ( "path" "path/filepath" - "github.com/AlexsanderHamir/prof/config" - "github.com/AlexsanderHamir/prof/shared" + "github.com/AlexsanderHamir/prof/internal/config" + "github.com/AlexsanderHamir/prof/internal/shared" ) const globalSign = "*" @@ -52,7 +52,7 @@ func RunCollector(files []string, tag string) error { } outputTextFilePath := path.Join(profileDirPath, fileName+"."+shared.TextExtension) - if err = GenerateProfileTextOutput(fullBinaryPath, outputTextFilePath); err != nil { + if err = GetProfileTextOutput(fullBinaryPath, outputTextFilePath); err != nil { return err } @@ -63,7 +63,7 @@ func RunCollector(files []string, tag string) error { return nil } -func GenerateProfileTextOutput(binaryFile, outputFile string) error { +func GetProfileTextOutput(binaryFile, outputFile string) error { pprofTextParams := getPprofTextParams() cmd := append([]string{"go", "tool", "pprof"}, pprofTextParams...) cmd = append(cmd, binaryFile) @@ -78,10 +78,10 @@ func GenerateProfileTextOutput(binaryFile, outputFile string) error { return os.WriteFile(outputFile, output, shared.PermFile) } -func GeneratePNGVisualization(binaryFile, outputFile string) error { +func GetPNGOutput(binaryFile, outputFile string) error { cmd := []string{"go", "tool", "pprof", "-png", binaryFile} - // #nosec G204 -- cmd is constructed internally by generatePNGVisualization(), not from user input + // #nosec G204 -- cmd is constructed internally by GetPNGOutput(), not from user input execCmd := exec.Command(cmd[0], cmd[1:]...) output, err := execCmd.Output() if err != nil { @@ -91,8 +91,8 @@ func GeneratePNGVisualization(binaryFile, outputFile string) error { return os.WriteFile(outputFile, output, shared.PermFile) } -// SaveAllFunctionsPprofContents calls [GetFunctionPprofContent] sequentially. -func SaveAllFunctionsPprofContents(functions []string, binaryPath, basePath string) error { +// GetFunctionsOutput calls [GetFunctionPprofContent] sequentially. +func GetFunctionsOutput(functions []string, binaryPath, basePath string) error { for _, functionName := range functions { outputFile := filepath.Join(basePath, functionName+"."+shared.TextExtension) if err := getFunctionPprofContent(functionName, binaryPath, outputFile); err != nil { diff --git a/collector/helpers.go b/engine/collector/helpers.go similarity index 89% rename from collector/helpers.go rename to engine/collector/helpers.go index 75f85ff..82a7e99 100644 --- a/collector/helpers.go +++ b/engine/collector/helpers.go @@ -7,9 +7,9 @@ import ( "os/exec" "path" - "github.com/AlexsanderHamir/prof/config" + "github.com/AlexsanderHamir/prof/internal/config" + "github.com/AlexsanderHamir/prof/internal/shared" "github.com/AlexsanderHamir/prof/parser" - "github.com/AlexsanderHamir/prof/shared" ) func ensureDirExists(basePath string) error { @@ -56,7 +56,7 @@ func collectFunctions(outputTextFilePath, profileDirPath, fullBinaryPath string, return err } - if err = SaveAllFunctionsPprofContents(functions, fullBinaryPath, functionDir); err != nil { + if err = GetFunctionsOutput(functions, fullBinaryPath, functionDir); err != nil { return fmt.Errorf("getAllFunctionsPprofContents failed: %w", err) } diff --git a/collector/utils.go b/engine/collector/utils.go similarity index 100% rename from collector/utils.go rename to engine/collector/utils.go diff --git a/tracker/api.go b/engine/tracker/api.go similarity index 98% rename from tracker/api.go rename to engine/tracker/api.go index 9c6b042..a6fa89a 100644 --- a/tracker/api.go +++ b/engine/tracker/api.go @@ -4,8 +4,8 @@ import ( "fmt" "path/filepath" + "github.com/AlexsanderHamir/prof/internal/shared" "github.com/AlexsanderHamir/prof/parser" - "github.com/AlexsanderHamir/prof/shared" ) // CheckPerformanceDifferences creates the profile report by comparing data from prof's auto run. diff --git a/tracker/function_change_result.go b/engine/tracker/function_change_result.go similarity index 100% rename from tracker/function_change_result.go rename to engine/tracker/function_change_result.go diff --git a/tracker/helpers.go b/engine/tracker/helpers.go similarity index 99% rename from tracker/helpers.go rename to engine/tracker/helpers.go index 880ed1f..4e75751 100644 --- a/tracker/helpers.go +++ b/engine/tracker/helpers.go @@ -7,8 +7,8 @@ import ( "strings" "time" + "github.com/AlexsanderHamir/prof/internal/shared" "github.com/AlexsanderHamir/prof/parser" - "github.com/AlexsanderHamir/prof/shared" ) func createHashFromLineObjects(lineobjects []*parser.LineObj) map[string]*parser.LineObj { diff --git a/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_block.txt b/engine/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_block.txt similarity index 100% rename from tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_block.txt rename to engine/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_block.txt diff --git a/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_cpu.txt b/engine/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_cpu.txt similarity index 100% rename from tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_cpu.txt rename to engine/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_cpu.txt diff --git a/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_memory.txt b/engine/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_memory.txt similarity index 100% rename from tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_memory.txt rename to engine/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_memory.txt diff --git a/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_mutex.txt b/engine/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_mutex.txt similarity index 100% rename from tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_mutex.txt rename to engine/tracker/tests/bench/tag1/text/BenchmarkGenPool/BenchmarkGenPool_mutex.txt diff --git a/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_block.txt b/engine/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_block.txt similarity index 100% rename from tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_block.txt rename to engine/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_block.txt diff --git a/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_cpu.txt b/engine/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_cpu.txt similarity index 100% rename from tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_cpu.txt rename to engine/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_cpu.txt diff --git a/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_memory.txt b/engine/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_memory.txt similarity index 100% rename from tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_memory.txt rename to engine/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_memory.txt diff --git a/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_mutex.txt b/engine/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_mutex.txt similarity index 100% rename from tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_mutex.txt rename to engine/tracker/tests/bench/tag2/text/BenchmarkGenPool/BenchmarkGenPool_mutex.txt diff --git a/tracker/tests/unit_test.go b/engine/tracker/tests/unit_test.go similarity index 94% rename from tracker/tests/unit_test.go rename to engine/tracker/tests/unit_test.go index 0521e94..8d574e2 100644 --- a/tracker/tests/unit_test.go +++ b/engine/tracker/tests/unit_test.go @@ -3,7 +3,7 @@ package tests_test import ( "testing" - "github.com/AlexsanderHamir/prof/tracker" + "github.com/AlexsanderHamir/prof/engine/tracker" ) func TestCoreBlock(t *testing.T) { diff --git a/tracker/types.go b/engine/tracker/types.go similarity index 100% rename from tracker/types.go rename to engine/tracker/types.go diff --git a/tracker/utils.go b/engine/tracker/utils.go similarity index 96% rename from tracker/utils.go rename to engine/tracker/utils.go index 628cb3b..8a651e2 100644 --- a/tracker/utils.go +++ b/engine/tracker/utils.go @@ -3,7 +3,7 @@ package tracker import ( "math" - "github.com/AlexsanderHamir/prof/shared" + "github.com/AlexsanderHamir/prof/internal/shared" ) const ( diff --git a/args/args.go b/internal/args/args.go similarity index 90% rename from args/args.go rename to internal/args/args.go index b62a5d3..8a8a6bc 100644 --- a/args/args.go +++ b/internal/args/args.go @@ -1,6 +1,6 @@ package args -import "github.com/AlexsanderHamir/prof/config" +import "github.com/AlexsanderHamir/prof/internal/config" type ModelCallRequiredArgs struct { SystemPrompt string diff --git a/config/api.go b/internal/config/api.go similarity index 96% rename from config/api.go rename to internal/config/api.go index 97bb9f2..c3bea41 100644 --- a/config/api.go +++ b/internal/config/api.go @@ -7,7 +7,7 @@ import ( "os" "path/filepath" - "github.com/AlexsanderHamir/prof/shared" + "github.com/AlexsanderHamir/prof/internal/shared" ) // LoadFromFile loads and validates config from a JSON file. diff --git a/config/types.go b/internal/config/types.go similarity index 100% rename from config/types.go rename to internal/config/types.go diff --git a/shared/utils.go b/internal/shared/utils.go similarity index 100% rename from shared/utils.go rename to internal/shared/utils.go diff --git a/version/version.go b/internal/version/version.go similarity index 100% rename from version/version.go rename to internal/version/version.go diff --git a/parser/api.go b/parser/api.go index cc6edb9..43c653b 100644 --- a/parser/api.go +++ b/parser/api.go @@ -7,9 +7,9 @@ import ( "regexp" "strings" - "github.com/AlexsanderHamir/prof/args" - "github.com/AlexsanderHamir/prof/config" - "github.com/AlexsanderHamir/prof/shared" + "github.com/AlexsanderHamir/prof/internal/args" + "github.com/AlexsanderHamir/prof/internal/config" + "github.com/AlexsanderHamir/prof/internal/shared" ) const ( diff --git a/parser/tests/unit_test.go b/parser/tests/unit_test.go index 59be15d..a7d6269 100644 --- a/parser/tests/unit_test.go +++ b/parser/tests/unit_test.go @@ -4,7 +4,7 @@ import ( "path/filepath" "testing" - "github.com/AlexsanderHamir/prof/args" + "github.com/AlexsanderHamir/prof/internal/args" "github.com/AlexsanderHamir/prof/parser" ) diff --git a/tests/blackbox_test.go b/tests/blackbox_test.go index df86915..8c08a7d 100644 --- a/tests/blackbox_test.go +++ b/tests/blackbox_test.go @@ -8,8 +8,8 @@ import ( "path" "testing" - "github.com/AlexsanderHamir/prof/config" - "github.com/AlexsanderHamir/prof/shared" + "github.com/AlexsanderHamir/prof/internal/config" + "github.com/AlexsanderHamir/prof/internal/shared" ) func TestConfig(t *testing.T) { diff --git a/tests/helpers.go b/tests/helpers.go index 0151f35..dc247bf 100644 --- a/tests/helpers.go +++ b/tests/helpers.go @@ -13,8 +13,8 @@ import ( "strings" "testing" - "github.com/AlexsanderHamir/prof/config" - "github.com/AlexsanderHamir/prof/shared" + "github.com/AlexsanderHamir/prof/internal/config" + "github.com/AlexsanderHamir/prof/internal/shared" ) var (