diff --git a/examples/worldcup/main.go b/examples/worldcup/main.go index f49bc5c5..e770a9d2 100644 --- a/examples/worldcup/main.go +++ b/examples/worldcup/main.go @@ -56,6 +56,7 @@ func initIOSDevice(uuid string) uixt.Device { perfOptions = append(perfOptions, hrp.WithPerfGPU(true)) } } + perfOptions = append(perfOptions, hrp.WithPerfOutputInterval(interval*1000)) device, err := uixt.NewIOSDevice( uixt.WithUDID(uuid), @@ -78,6 +79,7 @@ func initAndroidDevice(uuid string) uixt.Device { } type timeLog struct { + UTCTimeStr string `json:"utc_time_str"` UTCTime int64 `json:"utc_time"` LiveTime string `json:"live_time"` LiveTimeSeconds int `json:"live_time_seconds"` @@ -111,7 +113,7 @@ func NewWorldCupLive(device uixt.Device, matchName, bundleID string, duration, i startTime := time.Now() matchName = fmt.Sprintf("%s-%s", startTime.Format("2006-01-02"), matchName) - resultDir := filepath.Join("worldcup-archives", matchName, startTime.Format("15:04:05")) + resultDir := filepath.Join("worldcuplive", matchName, startTime.Format("15:04:05")) if err = os.MkdirAll(filepath.Join(resultDir, "screenshot"), 0o755); err != nil { log.Fatal().Err(err).Msg("failed to create result dir") @@ -168,6 +170,7 @@ func (wc *WorldCupLive) getCurrentLiveTime(utcTime time.Time) error { log.Error().Err(err).Str("line", line).Msg("write timeseries failed") } wc.Summary = append(wc.Summary, timeLog{ + UTCTimeStr: utcTimeStr, UTCTime: utcTime.Unix(), LiveTime: ocrText.Text, LiveTimeSeconds: liveTimeSeconds, @@ -256,6 +259,7 @@ func (wc *WorldCupLive) DumpResult() error { wc.PerfData = wc.driver.GetPerfData() err := encoder.Encode(wc) if err != nil { + log.Error().Err(err).Msg("encode json failed") return err } diff --git a/hrp/pkg/gidevice/perfd.go b/hrp/pkg/gidevice/perfd.go index e33b1c17..f4f1a6ff 100644 --- a/hrp/pkg/gidevice/perfd.go +++ b/hrp/pkg/gidevice/perfd.go @@ -5,6 +5,7 @@ import ( "encoding/binary" "encoding/json" "fmt" + "log" "net" "strconv" "time" @@ -179,10 +180,13 @@ type perfdSysmontap struct { func (c *perfdSysmontap) Start() (data <-chan []byte, err error) { // set config + interval := time.Millisecond * time.Duration(c.options.OutputInterval) + log.Printf("set sysmontap sample interval: %dms\n", c.options.OutputInterval) + config := map[string]interface{}{ "bm": 0, "cpuUsage": true, - "sampleInterval": time.Second * 1, // 1s + "sampleInterval": interval, // time.Duration "ur": c.options.OutputInterval, // 输出频率 "procAttrs": c.options.ProcessAttributes, // process performance "sysAttrs": c.options.SystemAttributes, // system performance @@ -740,7 +744,7 @@ func (c *perfdGraphicsOpengl) Start() (data <-chan []byte, err error) { if _, err = c.i.call( instrumentsServiceGraphicsOpengl, "setSamplingRate:", - float64(c.options.OutputInterval)/100, + float64(c.options.OutputInterval)/100, // FIXME: unable to set sampling rate, always 1.0 ); err != nil { return nil, err }