mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-06 16:07:45 +08:00
fix: remove time log
This commit is contained in:
@@ -1 +1 @@
|
|||||||
v5.0.0+2503032025
|
v5.0.0+2503032034
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
@@ -227,11 +226,7 @@ func saveScreenShot(raw *bytes.Buffer, fileName string) (string, error) {
|
|||||||
encoder := png.Encoder{
|
encoder := png.Encoder{
|
||||||
CompressionLevel: png.BestCompression,
|
CompressionLevel: png.BestCompression,
|
||||||
}
|
}
|
||||||
time1 := time.Now()
|
|
||||||
log.Info().Str("time1", time1.String()).Msg("png encode start")
|
|
||||||
err = encoder.Encode(file, img)
|
err = encoder.Encode(file, img)
|
||||||
time2 := time.Now()
|
|
||||||
log.Info().Int64("time", time2.Sub(time1).Milliseconds()).Msg("png encode time")
|
|
||||||
case "gif":
|
case "gif":
|
||||||
gifOptions := &gif.Options{
|
gifOptions := &gif.Options{
|
||||||
NumColors: 256,
|
NumColors: 256,
|
||||||
@@ -257,30 +252,26 @@ func saveScreenShot(raw *bytes.Buffer, fileName string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func compressImageBuffer(raw *bytes.Buffer) (compressed *bytes.Buffer, err error) {
|
func compressImageBuffer(raw *bytes.Buffer) (compressed *bytes.Buffer, err error) {
|
||||||
// 解码原始图像数据
|
// decode image from buffer
|
||||||
img, format, err := image.Decode(raw)
|
img, format, err := image.Decode(raw)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建一个用来保存压缩后数据的buffer
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
switch format {
|
switch format {
|
||||||
// Convert to jpeg uniformly and compress with a compression rate of 95
|
// compress image
|
||||||
case "jpeg", "png":
|
case "jpeg", "png":
|
||||||
jpegOptions := &jpeg.Options{Quality: 60}
|
jpegOptions := &jpeg.Options{Quality: 60}
|
||||||
time1 := time.Now()
|
|
||||||
err = jpeg.Encode(&buf, img, jpegOptions)
|
err = jpeg.Encode(&buf, img, jpegOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
time2 := time.Now()
|
|
||||||
log.Info().Int64("time", time2.Sub(time1).Milliseconds()).Msg("jpeg encode time")
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported image format: %s", format)
|
return nil, fmt.Errorf("unsupported image format: %s", format)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回压缩后的图像数据
|
// return compressed image buffer
|
||||||
return &buf, nil
|
return &buf, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user