From 6bc3e97a0868b64a07eeaacc1a5788681ebf9adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20H=C3=BCrzeler?= <55023662+joshuabeny1999@users.noreply.github.com> Date: Tue, 23 Mar 2021 18:06:46 +0100 Subject: [PATCH 1/2] Add time to go sample regex performance testing --- code/regex/go/regex.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/regex/go/regex.go b/code/regex/go/regex.go index 93097e32..35e9dbd2 100644 --- a/code/regex/go/regex.go +++ b/code/regex/go/regex.go @@ -1,6 +1,7 @@ package main import "fmt" +import "time" import "regexp" func main() { @@ -12,13 +13,15 @@ func main() { r2 += "a" regex := r1 + r2 r, err := regexp.Compile(regex) + start := time.Now() if err != nil { fmt.Println(err) } if r.MatchString(r2) { - fmt.Println(r2 + " matches " + regex) + duration := time.Since(start) + fmt.Println(r2 + " matches " + regex + " ", duration) } } } From 95a6fb2e2f4991eb29dcd02edac5ebb36ebf88b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Beny=20H=C3=BCrzeler?= <55023662+joshuabeny1999@users.noreply.github.com> Date: Wed, 7 Jul 2021 17:28:01 +0200 Subject: [PATCH 2/2] Update code/regex/go/regex.go Co-authored-by: Demian --- code/regex/go/regex.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/regex/go/regex.go b/code/regex/go/regex.go index 35e9dbd2..ffbd1ce3 100644 --- a/code/regex/go/regex.go +++ b/code/regex/go/regex.go @@ -20,8 +20,7 @@ func main() { } if r.MatchString(r2) { - duration := time.Since(start) - fmt.Println(r2 + " matches " + regex + " ", duration) + fmt.Sprintf("%s matches %s %dns", r2, regex, time.Since(start)) } } }