From 73ed18c9f59ae4adc545731977c1ce3a5c26b3f7 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期二, 06 八月 2019 11:20:17 +0800 Subject: [PATCH] add log --- service/FaceSdkService.go | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/service/FaceSdkService.go b/service/FaceSdkService.go index 43a4101..354bd00 100644 --- a/service/FaceSdkService.go +++ b/service/FaceSdkService.go @@ -33,19 +33,25 @@ ) func GetFaceFeaFromSdk(fileBytes []byte,deadTime time.Duration) ([]*protomsg.ResultFaceDetect,error,*protomsg.Image){ + tStart :=time.Now() s := NewFaceSdkService(fileBytes, deadTime) i, err := s.ReadFromUploadImg() + logger.Debug("ReadFromUploadImg鐢ㄦ椂锛�", time.Since(tStart)) if err !=nil{ logger.Debug("readFromUploadImg err:",err) return nil,err,i } + tStart = time.Now() bc, err := ImgCompress(i) + logger.Debug("ImgCompress鐢ㄦ椂锛�", time.Since(tStart)) if err !=nil { logger.Debug("ImgCompress err:",err) return nil,err,i } s.PushImgMsg(bc) + t1 := time.Now() s.GetFaceFea() + logger.Debug("GetFaceFea鐢ㄦ椂:", time.Since(t1)) if s.Result == nil{ return nil,errors.New("no fea"),i } else { @@ -116,13 +122,18 @@ } func ImgCompress(i *protomsg.Image) ([]byte,error){ + t1 := time.Now() if b, err := proto.Marshal(i); err != nil { logger.Debug("protoImage marshal err") return nil,err } else { + logger.Debug("proto.Marshal鐢ㄦ椂锛�", time.Since(t1)) + t1 = time.Now() bc := make([]byte, len(b)) ht := make([]int, 64<<10) n, err := lz4.CompressBlock(b, bc, ht) + logger.Debug("lz4.CompressBlock鐢ㄦ椂锛�", time.Since(t1)) + t1 = time.Now() if err != nil { logger.Debug(err) return nil,err @@ -132,6 +143,7 @@ return nil,errors.New("compressed len is 0") } bc = bc[:n] + logger.Debug("bc鐢ㄦ椂锛�", time.Since(t1)) return bc,nil } } -- Gitblit v1.8.0