Skip to content

Commit 0d1fdc4

Browse files
authored
check: make maxRenderTime configurable (#1057)
1 parent f4d5078 commit 0d1fdc4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cmd/check.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import (
1515
"tidbyt.dev/pixlet/tools"
1616
)
1717

18-
const MaxRenderTime = 1000000000 // 1000ms
18+
var maxRenderTime = time.Duration(1 * time.Second)
19+
20+
func init() {
21+
CheckCmd.Flags().BoolVarP(&rflag, "recursive", "r", false, "find apps recursively")
22+
CheckCmd.Flags().DurationVarP(&maxRenderTime, "max-render-time", "", maxRenderTime, "override the default max render time")
23+
}
1924

2025
var CheckCmd = &cobra.Command{
2126
Use: "check <path>...",
@@ -114,12 +119,12 @@ func checkCmd(cmd *cobra.Command, args []string) error {
114119
if err != nil {
115120
return fmt.Errorf("could not profile app: %w", err)
116121
}
117-
if p.DurationNanos > MaxRenderTime {
122+
if p.DurationNanos > maxRenderTime.Nanoseconds() {
118123
foundIssue = true
119124
failure(
120125
path,
121126
fmt.Errorf("app takes too long to render %s", time.Duration(p.DurationNanos)),
122-
fmt.Sprintf("try optimizing your app using `pixlet profile %s` to get it under %s", path, time.Duration(MaxRenderTime)),
127+
fmt.Sprintf("try optimizing your app using `pixlet profile %s` to get it under %s", path, time.Duration(maxRenderTime)),
123128
)
124129
continue
125130
}

0 commit comments

Comments
 (0)