diff --git a/cmd/check.go b/cmd/check.go index 25e4254650..2706850098 100644 --- a/cmd/check.go +++ b/cmd/check.go @@ -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{ @@ -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 }