Skip to content

Commit

Permalink
check: make maxRenderTime configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
matslina committed Apr 25, 2024
1 parent ff7ac7c commit a6180bc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import (
"tidbyt.dev/pixlet/manifest"
)

const MaxRenderTime = 1000000000 // 1000ms
var maxRenderTime = time.Duration(1 * time.Second)

func init() {
CheckCmd.Flags().BoolVarP(&rflag, "recursive", "r", false, "find apps recursively")
CheckCmd.Flags().DurationVarP(&maxRenderTime, "max-render-time", "", maxRenderTime, "override the default max render time")
}

var CheckCmd = &cobra.Command{
Expand Down Expand Up @@ -137,9 +138,9 @@ func checkCmd(cmd *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("could not profile app: %w", err)
}
if p.DurationNanos > MaxRenderTime {
if p.DurationNanos > maxRenderTime.Nanoseconds() {
foundIssue = true
failure(app, fmt.Errorf("app takes too long to render %s", time.Duration(p.DurationNanos)), fmt.Sprintf("try optimizing your app using `pixlet profile %s` to get it under %s", app, time.Duration(MaxRenderTime)))
failure(app, fmt.Errorf("app takes too long to render %s", time.Duration(p.DurationNanos)), fmt.Sprintf("try optimizing your app using `pixlet profile %s` to get it under %s", app, maxRenderTime))
continue
}

Expand Down

0 comments on commit a6180bc

Please sign in to comment.