Skip to content

Conversation

montag451
Copy link

@montag451 montag451 commented Sep 15, 2025

The improvement comes from the use of a cache to speed up the retrieval of struct fields. This commit also adds a new benchmark to measure the performance gain.

goos: linux
goarch: amd64
pkg: github.com/expr-lang/expr
cpu: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
                   │ /tmp/old.txt │            /tmp/new.txt             │
                   │    sec/op    │   sec/op     vs base                │
_envStruct_noEnv-8    503.3n ± 4%   228.8n ± 3%  -54.53% (p=0.000 n=10)

                   │ /tmp/old.txt │            /tmp/new.txt            │
                   │     B/op     │    B/op     vs base                │
_envStruct_noEnv-8     48.00 ± 0%   32.00 ± 0%  -33.33% (p=0.000 n=10)

                   │ /tmp/old.txt │            /tmp/new.txt            │
                   │  allocs/op   │ allocs/op   vs base                │
_envStruct_noEnv-8     3.000 ± 0%   1.000 ± 0%  -66.67% (p=0.000 n=10)

The improvement comes from the use of a cache to speed up the
retrieval of struct fields. This commit also adds a new benchmark to
measure the performance gain.

goos: linux
goarch: amd64
pkg: github.com/expr-lang/expr
cpu: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
                   │ /tmp/old.txt │            /tmp/new.txt             │
                   │    sec/op    │   sec/op     vs base                │
_envStruct_noEnv-8    503.3n ± 4%   228.8n ± 3%  -54.53% (p=0.000 n=10)

                   │ /tmp/old.txt │            /tmp/new.txt            │
                   │     B/op     │    B/op     vs base                │
_envStruct_noEnv-8     48.00 ± 0%   32.00 ± 0%  -33.33% (p=0.000 n=10)

                   │ /tmp/old.txt │            /tmp/new.txt            │
                   │  allocs/op   │ allocs/op   vs base                │
_envStruct_noEnv-8     3.000 ± 0%   1.000 ± 0%  -66.67% (p=0.000 n=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant