mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
feat: use startTime to correct sleep duration caused by process time
This commit is contained in:
@@ -244,7 +244,7 @@ func (l *LiveCrawler) Run(driver *DriverExt, enterPoint PointF) error {
|
||||
}
|
||||
|
||||
// sleep custom random time
|
||||
if err := sleepRandom(l.configs.Live.SleepRandom); err != nil {
|
||||
if err := sleepRandom(time.Now(), l.configs.Live.SleepRandom); err != nil {
|
||||
log.Error().Err(err).Msg("sleep random failed")
|
||||
}
|
||||
|
||||
@@ -352,6 +352,7 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
// loop until target count achieved or timeout
|
||||
// the main loop is feed crawler
|
||||
currVideoStat.timer = time.NewTimer(time.Duration(configs.Timeout) * time.Second)
|
||||
lastSwipeTime := time.Now()
|
||||
for {
|
||||
select {
|
||||
case <-currVideoStat.timer.C:
|
||||
@@ -400,7 +401,7 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
}
|
||||
|
||||
// sleep custom random time
|
||||
if err := sleepRandom(configs.Feed.SleepRandom); err != nil {
|
||||
if err := sleepRandom(lastSwipeTime, configs.Feed.SleepRandom); err != nil {
|
||||
log.Error().Err(err).Msg("sleep random failed")
|
||||
}
|
||||
|
||||
@@ -416,7 +417,7 @@ func (dExt *DriverExt) VideoCrawler(configs *VideoCrawlerConfigs) (err error) {
|
||||
log.Error().Err(err).Msg("swipe up failed")
|
||||
return err
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
lastSwipeTime = time.Now()
|
||||
|
||||
// check if feed page
|
||||
if err := dExt.Driver.AssertForegroundApp(configs.AppPackageName, "feed"); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user