Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions cli/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
10 changes: 5 additions & 5 deletions cli/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions benchmark/api.go → engine/benchmark/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/helpers.go → engine/benchmark/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"time"

"github.com/AlexsanderHamir/prof/shared"
"github.com/AlexsanderHamir/prof/internal/shared"
)

func getProfileFlags() map[string]string {
Expand Down
16 changes: 8 additions & 8 deletions collector/api.go → engine/collector/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "*"
Expand Down Expand Up @@ -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
}

Expand All @@ -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)
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions collector/helpers.go → engine/collector/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tracker/api.go → engine/tracker/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tracker/helpers.go → engine/tracker/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tracker/utils.go → engine/tracker/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package tracker
import (
"math"

"github.com/AlexsanderHamir/prof/shared"
"github.com/AlexsanderHamir/prof/internal/shared"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion args/args.go → internal/args/args.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package args

import "github.com/AlexsanderHamir/prof/config"
import "github.com/AlexsanderHamir/prof/internal/config"

type ModelCallRequiredArgs struct {
SystemPrompt string
Expand Down
2 changes: 1 addition & 1 deletion config/api.go → internal/config/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions parser/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion parser/tests/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"path/filepath"
"testing"

"github.com/AlexsanderHamir/prof/args"
"github.com/AlexsanderHamir/prof/internal/args"
"github.com/AlexsanderHamir/prof/parser"
)

Expand Down
4 changes: 2 additions & 2 deletions tests/blackbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Loading