Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize template replacement speed #33

Merged
merged 1 commit into from
Jun 25, 2024
Merged

Conversation

0fv
Copy link
Contributor

@0fv 0fv commented Jun 24, 2024

  1. fix clone() set parent method
  2. optimize expandPlaceholders(xnode *xmlNode) ,reduce loop time
  3. optimize replaceSingleParams(xnode *xmlNode, triggerParamOnly bool),reduce loop time

before:

goos: linux
goarch: amd64
pkg: github.com/bobiverse/docxplate
cpu: Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
BenchmarkLists100-6     1000000000               0.4386 ns/op
BenchmarkLists200-6            1        1693713947 ns/op
BenchmarkLists400-6            1        6552133541 ns/op
BenchmarkLists1000-6           1        40482876671 ns/op
PASS
ok      github.com/bobiverse/docxplate  60.426s

after:

goos: linux
goarch: amd64
pkg: github.com/bobiverse/docxplate
cpu: Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
BenchmarkLists100-6     1000000000               0.01451 ns/op
BenchmarkLists200-6     1000000000               0.02569 ns/op
BenchmarkLists400-6     1000000000               0.04924 ns/op
BenchmarkLists1000-6    1000000000               0.1187 ns/op
PASS
ok      github.com/bobiverse/docxplate  3.301s

Copy link
Owner

@bobiverse bobiverse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇‍♂️

@bobiverse bobiverse added the enhancement New feature or request label Jun 25, 2024
@bobiverse bobiverse merged commit 26ed7dd into bobiverse:master Jun 25, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants