phuslu / log

Fastest structured logging
MIT License
672 stars 44 forks source link

Add go-slog verify and bench testing #70

Closed madkins23 closed 5 months ago

madkins23 commented 5 months ago

This PR adds madkins23/go-slog verification and benchmark testing to your repository. If you're running bash the shell scripts should work when run from the top-level directory. You don't have to do this but I thought it might help.

Let me know if you try this and have issues with it. This is something I want to document and provide as an option for handler developers.

phuslu commented 5 months ago

thanks very much, this is what I really need. Let me give a try.

phuslu commented 5 months ago

the latest results is

verify.sh

=== RUN   TestVerifyPhusluSlog
:[ phuslu/slog
:: ^phuslu/slog^ is a wrapper around the pre-existing ^phuslu/log^ logging library.
:> phuslu/log --> https://github.com/phuslu/log
:]
=== RUN   TestVerifyPhusluSlog/TestAttributeDuplicate
=== RUN   TestVerifyPhusluSlog/TestAttributeEmptyName
=== RUN   TestVerifyPhusluSlog/TestAttributeNil
=== RUN   TestVerifyPhusluSlog/TestAttributeWithDuplicate
=== RUN   TestVerifyPhusluSlog/TestAttributeWithEmpty
=== RUN   TestVerifyPhusluSlog/TestAttributeWithEmptyName
=== RUN   TestVerifyPhusluSlog/TestAttributeWithNil
=== RUN   TestVerifyPhusluSlog/TestAttributes
=== RUN   TestVerifyPhusluSlog/TestAttributesEmpty
=== RUN   TestVerifyPhusluSlog/TestAttributesNotEmpty
=== RUN   TestVerifyPhusluSlog/TestAttributesWith
=== RUN   TestVerifyPhusluSlog/TestAttributesWithEmpty
=== RUN   TestVerifyPhusluSlog/TestAttributesWithNotEmpty
=== RUN   TestVerifyPhusluSlog/TestCanceledContext
=== RUN   TestVerifyPhusluSlog/TestComplexCases
    complex.go:96: 
            Error Trace:    /home/phuslu/go/pkg/mod/github.com/madkins23/go-slog@v0.9.8-beta-8/verify/tests/complex.go:96
            Error:          Not equal: 
                            expected: map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "group1":map[string]interface {}{"int":-13, "string":"value", "uint":23}, "level":"INFO", "msg":"This is a message"}
                            actual  : map[string]interface {}{"group1":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "int":-13, "string":"value", "uint":23}, "level":"INFO", "msg":"This is a message"}

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -1,6 +1,6 @@
                            -(map[string]interface {}) (len=6) {
                            - (string) (len=5) "aTime": (string) (len=25) "2024-05-03T00:03:55+08:00",
                            - (string) (len=4) "bool": (bool) true,
                            - (string) (len=8) "duration": (float64) 3.802e+06,
                            - (string) (len=6) "group1": (map[string]interface {}) (len=3) {
                            +(map[string]interface {}) (len=3) {
                            + (string) (len=6) "group1": (map[string]interface {}) (len=6) {
                            +  (string) (len=5) "aTime": (string) (len=25) "2024-05-03T00:03:55+08:00",
                            +  (string) (len=4) "bool": (bool) true,
                            +  (string) (len=8) "duration": (float64) 3.802e+06,
                               (string) (len=3) "int": (float64) -13,
            Test:           TestVerifyPhusluSlog/TestComplexCases
            Messages:       G1+A           M+B
    complex.go:96: 
            Error Trace:    /home/phuslu/go/pkg/mod/github.com/madkins23/go-slog@v0.9.8-beta-8/verify/tests/complex.go:96
            Error:          Not equal: 
                            expected: map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "group1":map[string]interface {}{"bool":false, "duration":1.429e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "valuer":"Big Tree"}, "level":"INFO", "msg":"This is a message"}
                            actual  : map[string]interface {}{"group1":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "valuer":"Big Tree"}, "level":"INFO", "msg":"This is a message"}

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -1,8 +1,6 @@
                            -(map[string]interface {}) (len=6) {
                            - (string) (len=5) "aTime": (string) (len=25) "2024-05-03T00:03:55+08:00",
                            - (string) (len=4) "bool": (bool) true,
                            - (string) (len=8) "duration": (float64) 3.802e+06,
                            - (string) (len=6) "group1": (map[string]interface {}) (len=4) {
                            -  (string) (len=4) "bool": (bool) false,
                            -  (string) (len=8) "duration": (float64) 1.429e+06,
                            +(map[string]interface {}) (len=3) {
                            + (string) (len=6) "group1": (map[string]interface {}) (len=5) {
                            +  (string) (len=5) "aTime": (string) (len=25) "2024-05-03T00:03:55+08:00",
                            +  (string) (len=4) "bool": (bool) true,
                            +  (string) (len=8) "duration": (float64) 3.802e+06,
                               (string) (len=6) "groupC": (map[string]interface {}) (len=3) {
            Test:           TestVerifyPhusluSlog/TestComplexCases
            Messages:       G1+C           M+B
    complex.go:96: 
            Error Trace:    /home/phuslu/go/pkg/mod/github.com/madkins23/go-slog@v0.9.8-beta-8/verify/tests/complex.go:96
            Error:          Not equal: 
                            expected: map[string]interface {}{"bool":false, "duration":1.429e+06, "group1":map[string]interface {}{"group2":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06}}, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "level":"INFO", "msg":"This is a message", "valuer":"Big Tree"}
                            actual  : map[string]interface {}{"group1":map[string]interface {}{"group2":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":false, "duration":1.429e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "valuer":"Big Tree"}}, "level":"INFO", "msg":"This is a message"}

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -1,19 +1,17 @@
                            -(map[string]interface {}) (len=7) {
                            - (string) (len=4) "bool": (bool) false,
                            - (string) (len=8) "duration": (float64) 1.429e+06,
                            +(map[string]interface {}) (len=3) {
                              (string) (len=6) "group1": (map[string]interface {}) (len=1) {
                            -  (string) (len=6) "group2": (map[string]interface {}) (len=3) {
                            +  (string) (len=6) "group2": (map[string]interface {}) (len=5) {
                                (string) (len=5) "aTime": (string) (len=25) "2024-05-03T00:03:55+08:00",
                            -   (string) (len=4) "bool": (bool) true,
                            -   (string) (len=8) "duration": (float64) 3.802e+06
                            +   (string) (len=4) "bool": (bool) false,
                            +   (string) (len=8) "duration": (float64) 1.429e+06,
                            +   (string) (len=6) "groupC": (map[string]interface {}) (len=3) {
                            +    (string) (len=4) "name": (string) (len=14) "Goober Snoofus",
                            +    (string) (len=2) "pi": (float64) 3.141592653589793,
                            +    (string) (len=6) "skidoo": (float64) 23
                            +   },
                            +   (string) (len=6) "valuer": (string) (len=8) "Big Tree"
                               }
                              },
                            - (string) (len=6) "groupC": (map[string]interface {}) (len=3) {
                            -  (string) (len=4) "name": (string) (len=14) "Goober Snoofus",
                            -  (string) (len=2) "pi": (float64) 3.141592653589793,
                            -  (string) (len=6) "skidoo": (float64) 23
                            - },
                              (string) (len=5) "level": (string) (len=4) "INFO",
                            - (string) (len=3) "msg": (string) (len=17) "This is a message",
                            - (string) (len=6) "valuer": (string) (len=8) "Big Tree"
                            + (string) (len=3) "msg": (string) (len=17) "This is a message"
                             }
            Test:           TestVerifyPhusluSlog/TestComplexCases
            Messages:       G1   G2+B      M+C
    complex.go:96: 
            Error Trace:    /home/phuslu/go/pkg/mod/github.com/madkins23/go-slog@v0.9.8-beta-8/verify/tests/complex.go:96
            Error:          Not equal: 
                            expected: map[string]interface {}{"bool":false, "duration":1.429e+06, "group1":map[string]interface {}{"group2":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06}, "int":-13, "string":"value", "uint":23}, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "level":"INFO", "msg":"This is a message", "valuer":"Big Tree"}
                            actual  : map[string]interface {}{"group1":map[string]interface {}{"group2":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":false, "duration":1.429e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "valuer":"Big Tree"}, "int":-13, "string":"value", "uint":23}, "level":"INFO", "msg":"This is a message"}

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -1,9 +1,13 @@
                            -(map[string]interface {}) (len=7) {
                            - (string) (len=4) "bool": (bool) false,
                            - (string) (len=8) "duration": (float64) 1.429e+06,
                            +(map[string]interface {}) (len=3) {
                              (string) (len=6) "group1": (map[string]interface {}) (len=4) {
                            -  (string) (len=6) "group2": (map[string]interface {}) (len=3) {
                            +  (string) (len=6) "group2": (map[string]interface {}) (len=5) {
                                (string) (len=5) "aTime": (string) (len=25) "2024-05-03T00:03:55+08:00",
                            -   (string) (len=4) "bool": (bool) true,
                            -   (string) (len=8) "duration": (float64) 3.802e+06
                            +   (string) (len=4) "bool": (bool) false,
                            +   (string) (len=8) "duration": (float64) 1.429e+06,
                            +   (string) (len=6) "groupC": (map[string]interface {}) (len=3) {
                            +    (string) (len=4) "name": (string) (len=14) "Goober Snoofus",
                            +    (string) (len=2) "pi": (float64) 3.141592653589793,
                            +    (string) (len=6) "skidoo": (float64) 23
                            +   },
                            +   (string) (len=6) "valuer": (string) (len=8) "Big Tree"
                               },
                            @@ -13,10 +17,4 @@
                              },
                            - (string) (len=6) "groupC": (map[string]interface {}) (len=3) {
                            -  (string) (len=4) "name": (string) (len=14) "Goober Snoofus",
                            -  (string) (len=2) "pi": (float64) 3.141592653589793,
                            -  (string) (len=6) "skidoo": (float64) 23
                            - },
                              (string) (len=5) "level": (string) (len=4) "INFO",
                            - (string) (len=3) "msg": (string) (len=17) "This is a message",
                            - (string) (len=6) "valuer": (string) (len=8) "Big Tree"
                            + (string) (len=3) "msg": (string) (len=17) "This is a message"
                             }
            Test:           TestVerifyPhusluSlog/TestComplexCases
            Messages:       G1+A G2+B      M+C
    complex.go:96: 
            Error Trace:    /home/phuslu/go/pkg/mod/github.com/madkins23/go-slog@v0.9.8-beta-8/verify/tests/complex.go:96
            Error:          Not equal: 
                            expected: map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "group1":map[string]interface {}{"group2":map[string]interface {}{"group3":map[string]interface {}{"bool":false, "duration":1.429e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "valuer":"Big Tree"}}}, "level":"INFO", "msg":"This is a message"}
                            actual  : map[string]interface {}{"group1":map[string]interface {}{"group2":map[string]interface {}{"group3":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "valuer":"Big Tree"}}}, "level":"INFO", "msg":"This is a message"}

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -1,10 +1,8 @@
                            -(map[string]interface {}) (len=6) {
                            - (string) (len=5) "aTime": (string) (len=25) "2024-05-03T00:03:55+08:00",
                            - (string) (len=4) "bool": (bool) true,
                            - (string) (len=8) "duration": (float64) 3.802e+06,
                            +(map[string]interface {}) (len=3) {
                              (string) (len=6) "group1": (map[string]interface {}) (len=1) {
                               (string) (len=6) "group2": (map[string]interface {}) (len=1) {
                            -   (string) (len=6) "group3": (map[string]interface {}) (len=4) {
                            -    (string) (len=4) "bool": (bool) false,
                            -    (string) (len=8) "duration": (float64) 1.429e+06,
                            +   (string) (len=6) "group3": (map[string]interface {}) (len=5) {
                            +    (string) (len=5) "aTime": (string) (len=25) "2024-05-03T00:03:55+08:00",
                            +    (string) (len=4) "bool": (bool) true,
                            +    (string) (len=8) "duration": (float64) 3.802e+06,
                                 (string) (len=6) "groupC": (map[string]interface {}) (len=3) {
            Test:           TestVerifyPhusluSlog/TestComplexCases
            Messages:       G1   G2   G3+C M+B
    complex.go:96: 
            Error Trace:    /home/phuslu/go/pkg/mod/github.com/madkins23/go-slog@v0.9.8-beta-8/verify/tests/complex.go:96
            Error:          Not equal: 
                            expected: map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "group1":map[string]interface {}{"group2":map[string]interface {}{"group3":map[string]interface {}{"bool":false, "duration":1.429e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "valuer":"Big Tree"}}, "int":-13, "string":"value", "uint":23}, "level":"INFO", "msg":"This is a message"}
                            actual  : map[string]interface {}{"group1":map[string]interface {}{"group2":map[string]interface {}{"group3":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "valuer":"Big Tree"}}, "int":-13, "string":"value", "uint":23}, "level":"INFO", "msg":"This is a message"}

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -1,10 +1,8 @@
                            -(map[string]interface {}) (len=6) {
                            - (string) (len=5) "aTime": (string) (len=25) "2024-05-03T00:03:55+08:00",
                            - (string) (len=4) "bool": (bool) true,
                            - (string) (len=8) "duration": (float64) 3.802e+06,
                            +(map[string]interface {}) (len=3) {
                              (string) (len=6) "group1": (map[string]interface {}) (len=4) {
                               (string) (len=6) "group2": (map[string]interface {}) (len=1) {
                            -   (string) (len=6) "group3": (map[string]interface {}) (len=4) {
                            -    (string) (len=4) "bool": (bool) false,
                            -    (string) (len=8) "duration": (float64) 1.429e+06,
                            +   (string) (len=6) "group3": (map[string]interface {}) (len=5) {
                            +    (string) (len=5) "aTime": (string) (len=25) "2024-05-03T00:03:55+08:00",
                            +    (string) (len=4) "bool": (bool) true,
                            +    (string) (len=8) "duration": (float64) 3.802e+06,
                                 (string) (len=6) "groupC": (map[string]interface {}) (len=3) {
            Test:           TestVerifyPhusluSlog/TestComplexCases
            Messages:       G1+A G2   G3+C M+B
    complex.go:96: 
            Error Trace:    /home/phuslu/go/pkg/mod/github.com/madkins23/go-slog@v0.9.8-beta-8/verify/tests/complex.go:96
            Error:          Not equal: 
                            expected: map[string]interface {}{"group1":map[string]interface {}{"group2":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "group3":map[string]interface {}{"bool":false, "duration":1.429e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "valuer":"Big Tree"}}}, "int":-13, "level":"INFO", "msg":"This is a message", "string":"value", "uint":23}
                            actual  : map[string]interface {}{"group1":map[string]interface {}{"group2":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "group3":map[string]interface {}{"bool":false, "duration":1.429e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "int":-13, "string":"value", "uint":23, "valuer":"Big Tree"}}}, "level":"INFO", "msg":"This is a message"}

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -1,2 +1,2 @@
                            -(map[string]interface {}) (len=6) {
                            +(map[string]interface {}) (len=3) {
                              (string) (len=6) "group1": (map[string]interface {}) (len=1) {
                            @@ -6,3 +6,3 @@
                                (string) (len=8) "duration": (float64) 3.802e+06,
                            -   (string) (len=6) "group3": (map[string]interface {}) (len=4) {
                            +   (string) (len=6) "group3": (map[string]interface {}) (len=7) {
                                 (string) (len=4) "bool": (bool) false,
                            @@ -14,2 +14,5 @@
                                 },
                            +    (string) (len=3) "int": (float64) -13,
                            +    (string) (len=6) "string": (string) (len=5) "value",
                            +    (string) (len=4) "uint": (float64) 23,
                                 (string) (len=6) "valuer": (string) (len=8) "Big Tree"
                            @@ -18,7 +21,4 @@
                              },
                            - (string) (len=3) "int": (float64) -13,
                              (string) (len=5) "level": (string) (len=4) "INFO",
                            - (string) (len=3) "msg": (string) (len=17) "This is a message",
                            - (string) (len=6) "string": (string) (len=5) "value",
                            - (string) (len=4) "uint": (float64) 23
                            + (string) (len=3) "msg": (string) (len=17) "This is a message"
                             }
            Test:           TestVerifyPhusluSlog/TestComplexCases
            Messages:       G1   G2+B G3+C M+A
    complex.go:96: 
            Error Trace:    /home/phuslu/go/pkg/mod/github.com/madkins23/go-slog@v0.9.8-beta-8/verify/tests/complex.go:96
            Error:          Not equal: 
                            expected: map[string]interface {}{"E":2.718281828459045, "group1":map[string]interface {}{"group2":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "group3":map[string]interface {}{"bool":false, "duration":1.429e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "valuer":"Big Tree"}}, "int":-13, "string":"value", "uint":23}, "level":"INFO", "msg":"This is a message", "uint64":79}
                            actual  : map[string]interface {}{"group1":map[string]interface {}{"group2":map[string]interface {}{"aTime":"2024-05-03T00:03:55+08:00", "bool":true, "duration":3.802e+06, "group3":map[string]interface {}{"E":2.718281828459045, "bool":false, "duration":1.429e+06, "groupC":map[string]interface {}{"name":"Goober Snoofus", "pi":3.141592653589793, "skidoo":23}, "uint64":79, "valuer":"Big Tree"}}, "int":-13, "string":"value", "uint":23}, "level":"INFO", "msg":"This is a message"}

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -1,3 +1,2 @@
                            -(map[string]interface {}) (len=5) {
                            - (string) (len=1) "E": (float64) 2.718281828459045,
                            +(map[string]interface {}) (len=3) {
                              (string) (len=6) "group1": (map[string]interface {}) (len=4) {
                            @@ -7,3 +6,4 @@
                                (string) (len=8) "duration": (float64) 3.802e+06,
                            -   (string) (len=6) "group3": (map[string]interface {}) (len=4) {
                            +   (string) (len=6) "group3": (map[string]interface {}) (len=6) {
                            +    (string) (len=1) "E": (float64) 2.718281828459045,
                                 (string) (len=4) "bool": (bool) false,
                            @@ -15,2 +15,3 @@
                                 },
                            +    (string) (len=6) "uint64": (float64) 79,
                                 (string) (len=6) "valuer": (string) (len=8) "Big Tree"
                            @@ -23,4 +24,3 @@
                              (string) (len=5) "level": (string) (len=4) "INFO",
                            - (string) (len=3) "msg": (string) (len=17) "This is a message",
                            - (string) (len=6) "uint64": (float64) 79
                            + (string) (len=3) "msg": (string) (len=17) "This is a message"
                             }
            Test:           TestVerifyPhusluSlog/TestComplexCases
            Messages:       G1+A G2+B G3+C M+D
=== RUN   TestVerifyPhusluSlog/TestDefaultLevel
=== RUN   TestVerifyPhusluSlog/TestDerivedInvariantWith
=== RUN   TestVerifyPhusluSlog/TestDerivedInvariantWithGroup
=== RUN   TestVerifyPhusluSlog/TestDisabled
=== RUN   TestVerifyPhusluSlog/TestGroup
=== RUN   TestVerifyPhusluSlog/TestGroupDuration
=== RUN   TestVerifyPhusluSlog/TestGroupEmpty
=== RUN   TestVerifyPhusluSlog/TestGroupInline
=== RUN   TestVerifyPhusluSlog/TestGroupWith
=== RUN   TestVerifyPhusluSlog/TestGroupWithMulti
=== RUN   TestVerifyPhusluSlog/TestGroupWithMultiSubEmpty
=== RUN   TestVerifyPhusluSlog/TestGroupWithTop
=== RUN   TestVerifyPhusluSlog/TestKeyCase
=== RUN   TestVerifyPhusluSlog/TestKeys
=== RUN   TestVerifyPhusluSlog/TestLevelConfigured
=== RUN   TestVerifyPhusluSlog/TestLevelDifferent
=== RUN   TestVerifyPhusluSlog/TestLevelVar
=== RUN   TestVerifyPhusluSlog/TestLogAttributes
=== RUN   TestVerifyPhusluSlog/TestReplaceAttr
=== RUN   TestVerifyPhusluSlog/TestReplaceAttrBasic
=== RUN   TestVerifyPhusluSlog/TestReplaceAttrFnChangeKey
=== RUN   TestVerifyPhusluSlog/TestReplaceAttrFnLevelCase
=== RUN   TestVerifyPhusluSlog/TestReplaceAttrFnMulti
=== RUN   TestVerifyPhusluSlog/TestReplaceAttrFnRemoveEmptyKey
=== RUN   TestVerifyPhusluSlog/TestReplaceAttrFnRemoveTime
=== RUN   TestVerifyPhusluSlog/TestReplaceAttrGroup
=== RUN   TestVerifyPhusluSlog/TestResolveGroup
=== RUN   TestVerifyPhusluSlog/TestResolveGroupWith
=== RUN   TestVerifyPhusluSlog/TestResolveValuer
=== RUN   TestVerifyPhusluSlog/TestResolveWith
=== RUN   TestVerifyPhusluSlog/TestSlogTest
=== RUN   TestVerifyPhusluSlog/TestSourceKey
=== RUN   TestVerifyPhusluSlog/TestStringEscape
=== RUN   TestVerifyPhusluSlog/TestTimestampFormat
=== RUN   TestVerifyPhusluSlog/TestWithGroupEmpty
=== RUN   TestVerifyPhusluSlog/TestWithGroupInline
=== RUN   TestVerifyPhusluSlog/TestZeroPC
=== RUN   TestVerifyPhusluSlog/TestZeroTime
--- FAIL: TestVerifyPhusluSlog (0.04s)
    --- PASS: TestVerifyPhusluSlog/TestAttributeDuplicate (0.01s)
    --- PASS: TestVerifyPhusluSlog/TestAttributeEmptyName (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestAttributeNil (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestAttributeWithDuplicate (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestAttributeWithEmpty (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestAttributeWithEmptyName (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestAttributeWithNil (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestAttributes (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestAttributesEmpty (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestAttributesNotEmpty (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestAttributesWith (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestAttributesWithEmpty (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestAttributesWithNotEmpty (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestCanceledContext (0.00s)
    --- FAIL: TestVerifyPhusluSlog/TestComplexCases (0.01s)
    --- PASS: TestVerifyPhusluSlog/TestDefaultLevel (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestDerivedInvariantWith (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestDerivedInvariantWithGroup (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestDisabled (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestGroup (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestGroupDuration (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestGroupEmpty (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestGroupInline (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestGroupWith (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestGroupWithMulti (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestGroupWithMultiSubEmpty (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestGroupWithTop (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestKeyCase (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestKeys (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestLevelConfigured (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestLevelDifferent (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestLevelVar (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestLogAttributes (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestReplaceAttr (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestReplaceAttrBasic (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestReplaceAttrFnChangeKey (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestReplaceAttrFnLevelCase (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestReplaceAttrFnMulti (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestReplaceAttrFnRemoveEmptyKey (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestReplaceAttrFnRemoveTime (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestReplaceAttrGroup (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestResolveGroup (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestResolveGroupWith (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestResolveValuer (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestResolveWith (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestSlogTest (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestSourceKey (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestStringEscape (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestTimestampFormat (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestWithGroupEmpty (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestWithGroupInline (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestZeroPC (0.00s)
    --- PASS: TestVerifyPhusluSlog/TestZeroTime (0.00s)
FAIL
FAIL    github.com/phuslu/log/go_slog/verify    0.104s
FAIL

bench.sh

goos: linux
goarch: arm64
pkg: github.com/phuslu/log/go_slog/bench
BenchmarkPhusluSlog/BenchmarkAttributes-4            1359282           855.6 ns/op   513.10 MB/s         344 B/op          5 allocs/op
BenchmarkPhusluSlog/BenchmarkBigGroup-4                10000        109792 ns/op     126.42 MB/s      204995 B/op       1423 allocs/op
BenchmarkPhusluSlog/BenchmarkDisabled-4             457580678            2.642 ns/op           0 B/op          0 allocs/op
BenchmarkPhusluSlog/BenchmarkKeyValues-4             1327142           897.1 ns/op   488.25 MB/s         344 B/op          5 allocs/op
BenchmarkPhusluSlog/BenchmarkLogging-4                 89149         13708 ns/op     660.69 MB/s           0 B/op          0 allocs/op
BenchmarkPhusluSlog/BenchmarkSimple-4                6989562           180.1 ns/op   488.53 MB/s           0 B/op          0 allocs/op
BenchmarkPhusluSlog/BenchmarkSimpleSource-4          5137153           238.8 ns/op  1319.07 MB/s          24 B/op          1 allocs/op
BenchmarkPhusluSlog/BenchmarkWithAttrsAttributes-4           1357988           876.9 ns/op   937.42 MB/s         344 B/op          5 allocs/op
BenchmarkPhusluSlog/BenchmarkWithAttrsKeyValues-4            1305096           915.4 ns/op   897.92 MB/s         344 B/op          5 allocs/op
BenchmarkPhusluSlog/BenchmarkWithAttrsSimple-4               6649012           183.6 ns/op  2565.77 MB/s           0 B/op          0 allocs/op
BenchmarkPhusluSlog/BenchmarkWithGroupAttributes-4           1350495           875.4 ns/op   517.45 MB/s         344 B/op          5 allocs/op
BenchmarkPhusluSlog/BenchmarkWithGroupKeyValues-4            1277612           930.6 ns/op   486.79 MB/s         344 B/op          5 allocs/op
PASS
ok      github.com/phuslu/log/go_slog/bench 20.788s

After the latest refactor, the bench results look better now. And I will continue to look the verification fails. thanks aganin.

phuslu commented 5 months ago

After re-instate sync.Pool to "eval" slog.Group, the allocs of benchmark deceased and throughputs slightly improved.

goos: linux
goarch: arm64
pkg: go_slog/bench
BenchmarkPhusluSlog/BenchmarkAttributes-4            1451938           837.2 ns/op   524.34 MB/s         288 B/op          2 allocs/op
BenchmarkPhusluSlog/BenchmarkBigGroup-4                38733         30745 ns/op     161.98 MB/s       58256 B/op        510 allocs/op
BenchmarkPhusluSlog/BenchmarkDisabled-4             457571262            2.637 ns/op           0 B/op          0 allocs/op
BenchmarkPhusluSlog/BenchmarkKeyValues-4             1372089           883.9 ns/op   496.69 MB/s         288 B/op          2 allocs/op
BenchmarkPhusluSlog/BenchmarkLogging-4                 89436         13493 ns/op     671.22 MB/s           0 B/op          0 allocs/op
BenchmarkPhusluSlog/BenchmarkSimple-4                7042221           172.3 ns/op   510.71 MB/s           0 B/op          0 allocs/op
BenchmarkPhusluSlog/BenchmarkSimpleSource-4          5234323           236.0 ns/op  1334.93 MB/s          24 B/op          1 allocs/op
BenchmarkPhusluSlog/BenchmarkWithAttrsAttributes-4           1406270           840.9 ns/op   977.55 MB/s         288 B/op          2 allocs/op
BenchmarkPhusluSlog/BenchmarkWithAttrsKeyValues-4            1342380           898.1 ns/op   915.24 MB/s         288 B/op          2 allocs/op
BenchmarkPhusluSlog/BenchmarkWithAttrsSimple-4               6786357           181.9 ns/op  2588.85 MB/s           0 B/op          0 allocs/op
BenchmarkPhusluSlog/BenchmarkWithGroupAttributes-4           1420014           841.9 ns/op   538.09 MB/s         288 B/op          2 allocs/op
BenchmarkPhusluSlog/BenchmarkWithGroupKeyValues-4            1341351           893.4 ns/op   507.02 MB/s         288 B/op          2 allocs/op
PASS
ok      go_slog/bench   21.157s

@madkins23 thanks for this, it helps a lot and I will start to look the verify "Warning" results.