mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 00:17:37 +08:00
remove unused endtoenddelay directory
This commit is contained in:
@@ -1,16 +1,13 @@
|
|||||||
package uixt
|
package uixt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/httprunner/funplugin/myexec"
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,36 +21,16 @@ type timeLog struct {
|
|||||||
|
|
||||||
type EndToEndDelay struct {
|
type EndToEndDelay struct {
|
||||||
driver *DriverExt
|
driver *DriverExt
|
||||||
file *os.File
|
|
||||||
resultDir string
|
|
||||||
UUID string `json:"uuid"`
|
|
||||||
AppName string `json:"appName"`
|
|
||||||
BundleID string `json:"bundleID"`
|
|
||||||
StartTime string `json:"startTime"`
|
StartTime string `json:"startTime"`
|
||||||
EndTime string `json:"endTime"`
|
EndTime string `json:"endTime"`
|
||||||
Interval int `json:"interval"` // seconds
|
Interval int `json:"interval"` // seconds
|
||||||
Duration int `json:"duration"` // seconds
|
Duration int `json:"duration"` // seconds
|
||||||
Timelines []timeLog `json:"timelines"`
|
Timelines []timeLog `json:"timelines"`
|
||||||
PerfFile string `json:"perf"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) CollectEndToEndDelay(options ...ActionOption) {
|
func (dExt *DriverExt) CollectEndToEndDelay(options ...ActionOption) {
|
||||||
dataOptions := NewActionOptions(options...)
|
dataOptions := NewActionOptions(options...)
|
||||||
var err error
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
resultDir := filepath.Join("endtoenddelay", startTime.Format("2006-01-02 15:04:05"))
|
|
||||||
|
|
||||||
if err = os.MkdirAll(filepath.Join(resultDir, "screenshot"), 0o755); err != nil {
|
|
||||||
log.Fatal().Err(err).Msg("failed to create result dir")
|
|
||||||
}
|
|
||||||
|
|
||||||
filename := filepath.Join(resultDir, "log.txt")
|
|
||||||
f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0o755)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal().Err(err).Msg("failed to open file")
|
|
||||||
}
|
|
||||||
// write title
|
|
||||||
f.WriteString("utc_time\tutc_timestamp\tlive_time\tlive_seconds\n")
|
|
||||||
|
|
||||||
if dataOptions.Interval == 0 {
|
if dataOptions.Interval == 0 {
|
||||||
dataOptions.Interval = 5
|
dataOptions.Interval = 5
|
||||||
@@ -64,15 +41,11 @@ func (dExt *DriverExt) CollectEndToEndDelay(options ...ActionOption) {
|
|||||||
|
|
||||||
endToEndDelay := &EndToEndDelay{
|
endToEndDelay := &EndToEndDelay{
|
||||||
driver: dExt,
|
driver: dExt,
|
||||||
file: f,
|
|
||||||
resultDir: resultDir,
|
|
||||||
Duration: int(dataOptions.Timeout),
|
Duration: int(dataOptions.Timeout),
|
||||||
Interval: int(dataOptions.Interval),
|
Interval: int(dataOptions.Interval),
|
||||||
StartTime: startTime.Format("2006-01-02 15:04:05"),
|
StartTime: startTime.Format("2006-01-02 15:04:05"),
|
||||||
}
|
}
|
||||||
|
|
||||||
SntpCheckTime()
|
|
||||||
|
|
||||||
endToEndDelay.Start()
|
endToEndDelay.Start()
|
||||||
|
|
||||||
dExt.cacheStepData.e2eDelay = endToEndDelay.Timelines
|
dExt.cacheStepData.e2eDelay = endToEndDelay.Timelines
|
||||||
@@ -122,8 +95,6 @@ func (ete *EndToEndDelay) getCurrentLiveTime(utcTime time.Time) error {
|
|||||||
liveTimeNSInt = 0
|
liveTimeNSInt = 0
|
||||||
}
|
}
|
||||||
liveTimeStr := time.Unix(int64(liveTimeSInt), int64(liveTimeNSInt*1000*1000)).Format("2006-01-02 15:04:05")
|
liveTimeStr := time.Unix(int64(liveTimeSInt), int64(liveTimeNSInt*1000*1000)).Format("2006-01-02 15:04:05")
|
||||||
line := fmt.Sprintf("%s\t%d\t%s\t%s\n",
|
|
||||||
utcTimeStr, utcTime.UnixMicro(), liveTimeStr, liveTimeText)
|
|
||||||
log.Info().
|
log.Info().
|
||||||
Str("utcTime", utcTimeStr).
|
Str("utcTime", utcTimeStr).
|
||||||
Int64("utcTimeInt", utcTime.UnixMilli()).
|
Int64("utcTimeInt", utcTime.UnixMilli()).
|
||||||
@@ -131,9 +102,6 @@ func (ete *EndToEndDelay) getCurrentLiveTime(utcTime time.Time) error {
|
|||||||
Int64("liveTimeInt", int64(liveTimeInt)).
|
Int64("liveTimeInt", int64(liveTimeInt)).
|
||||||
Float64("delay", float64(utcTime.UnixMilli()-int64(liveTimeInt))/1000).
|
Float64("delay", float64(utcTime.UnixMilli()-int64(liveTimeInt))/1000).
|
||||||
Msg("log live time")
|
Msg("log live time")
|
||||||
if _, err := ete.file.WriteString(line); err != nil {
|
|
||||||
log.Error().Err(err).Str("line", line).Msg("write timeseries failed")
|
|
||||||
}
|
|
||||||
ete.Timelines = append(ete.Timelines, timeLog{
|
ete.Timelines = append(ete.Timelines, timeLog{
|
||||||
UTCTimeStr: utcTimeStr,
|
UTCTimeStr: utcTimeStr,
|
||||||
UTCTime: utcTime.UnixMilli(),
|
UTCTime: utcTime.UnixMilli(),
|
||||||
@@ -151,8 +119,10 @@ func (ete *EndToEndDelay) Start() {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
|
ete.EndTime = time.Now().Format("2006-01-02 15:04:05")
|
||||||
return
|
return
|
||||||
case <-c:
|
case <-c:
|
||||||
|
ete.EndTime = time.Now().Format("2006-01-02 15:04:05")
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
utcTime := time.Now()
|
utcTime := time.Now()
|
||||||
@@ -164,10 +134,3 @@ func (ete *EndToEndDelay) Start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SntpCheckTime() {
|
|
||||||
err := myexec.RunCommand("sudo", "sntp", "-sS", "time.asia.apple.com")
|
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).Msg("failed to synchronize time using sntp")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user