From cb256004a134b9db7c9607d5e5b760d7ac2aec9f Mon Sep 17 00:00:00 2001 From: Daniel Christian Schroeter <2836188+danielchristianschroeter@users.noreply.github.com> Date: Wed, 3 Jul 2024 14:22:02 +0200 Subject: [PATCH] one total execution time is enough --- README.md | 9 +++------ main.go | 20 +++++--------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 78b7926..4281109 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,14 @@ You can request trial access on https://bwsportal.bioid.com/register 2. Execute following command to perform a photo verify with two images: ``` - .\BioIDWebService-PhotoVerify-gRPC-Sample-In-Go.exe -BWSClientID -BWSKey -photo example_images\photo.jpg -image1 example_images\testimage1.jpg -image2 example_images\testimage2.jpg + .\BioIDWebService-PhotoVerify-gRPC-Sample-In-Go -BWSClientID -BWSKey -photo example_images\photo.jpg -image1 example_images\testimage1.jpg -image2 example_images\testimage2.jpg ``` Example Output: ``` -Token generation took: 0s -Client creation took: 519.8µs -File reading took: 536.2µs -Photo verification took: 921.5775ms +Total execution time: 954.999ms + Verification Status: SUCCEEDED Verification Errors: [error_code:"RejectedByPassiveLiveDetection" message:"At least one of the live images seem not to be recorded from a live person." error_code:"RejectedByPassiveLiveDetection" message:"At least one of the live images seem not to be recorded from a live person."] Verification ImageProperties: [faces:{left_eye:{x:716.6898478956991 y:295.90328987385425} right_eye:{x:583.7671688344084 y:295.6642189519129} texture_liveness_score:0.36677824126349556} faces:{left_eye:{x:493.984682522074 y:253.9819667801256} right_eye:{x:382.02615043197886 y:250.22897896148734} texture_liveness_score:0.46766824192470974}] @@ -33,7 +31,6 @@ Verification Level: NOT_RECOGNIZED Verification Score: 0 Verification Live: false Verification LivenessScore: 0.46766824192470974 -Total execution time: 923.6721ms ``` ### Available command line parameter diff --git a/main.go b/main.go index 737cb8e..c21ef43 100644 --- a/main.go +++ b/main.go @@ -88,7 +88,6 @@ func init() { } func main() { - startTime := time.Now() // Record the start time of the entire process log.SetFlags(0) flag.Usage = func() { @@ -101,24 +100,19 @@ func main() { log.Fatal("Usage: -BWSClientID -BWSKey -photo -image1 [-image2 ]") } - tokenStart := time.Now() // Measure time to generate the token + startTime := time.Now() // Record the start time of the entire process + token, err := generateToken(BWSClientID, BWSKey, 5) if err != nil { log.Fatalf("Failed to generate token: %v", err) } - tokenDuration := time.Since(tokenStart) - fmt.Printf("Token generation took: %v\n", tokenDuration) - - clientCreationStart := time.Now() // Measure time to create the authenticated client + conn, client, err := createAuthenticatedClient() if err != nil { log.Fatalf("Failed to create client: %v", err) } defer conn.Close() - clientCreationDuration := time.Since(clientCreationStart) - fmt.Printf("Client creation took: %v\n", clientCreationDuration) - fileReadStart := time.Now() // Measure time to read all files var wg sync.WaitGroup wg.Add(2) if image2Path != "" { @@ -135,7 +129,6 @@ func main() { } wg.Wait() - fmt.Printf("File reading took: %v\n", time.Since(fileReadStart)) if err1 != nil { log.Fatalf("Failed to read live image 1: %v", err1) @@ -158,7 +151,6 @@ func main() { request.LiveImages = append(request.LiveImages, &pb.ImageData{Image: liveImage2}) } - photoVerifyStart := time.Now() // Measure time to verify photo ctx := context.Background() ctx = metadata.AppendToOutgoingContext(ctx, "authorization", "Bearer "+token) @@ -166,10 +158,10 @@ func main() { if err != nil { log.Fatalf("Failed to verify photo: %v", err) } - photoVerifyDuration := time.Since(photoVerifyStart) - fmt.Printf("Photo verification took: %v\n", photoVerifyDuration) // Print the results + fmt.Printf("Total execution time: %v\n", time.Since(startTime)) // Print the total execution time + fmt.Println() fmt.Printf("Verification Status: %v\n", response.Status) fmt.Printf("Verification Errors: %v\n", response.Errors) fmt.Printf("Verification ImageProperties: %v\n", response.ImageProperties) @@ -178,6 +170,4 @@ func main() { fmt.Printf("Verification Score: %v\n", response.VerificationScore) fmt.Printf("Verification Live: %v\n", response.Live) fmt.Printf("Verification LivenessScore: %v\n", response.LivenessScore) - - fmt.Printf("Total execution time: %v\n", time.Since(startTime)) // Print the total execution time } \ No newline at end of file