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

refactor(tools/string): speed up strip (whitespace) #13168

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

bungle
Copy link
Member

@bungle bungle commented Jun 5, 2024

Summary

With simple microbenchmark:

ngx.update_time()
local s = ngx.now()
for i = 1, 100000 do
    local a = strip("           \t \ndogestr   \f\t\r ")
end
ngx.update_time()
local e = ngx.now()

print("took: ", (e * 1000) - (s * 1000), " ms")

I get these results:
Current: took: 57 ms
PR: took: 7 ms

KAG-4684

@bungle bungle requested a review from chronolaw June 5, 2024 19:52
@github-actions github-actions bot added the cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee label Jun 5, 2024
kong/tools/string.lua Outdated Show resolved Hide resolved
kong/tools/string.lua Outdated Show resolved Hide resolved
@bungle bungle force-pushed the refactor/speed-up-strip branch 3 times, most recently from c734467 to 4450845 Compare June 6, 2024 06:57
### Summary

With simple microbenchmark:
```lua
ngx.update_time()
local s = ngx.now()
for i = 1, 100000 do
    local a = strip("           \t \ndogestr   \f\t\r ")
end
ngx.update_time()
local e = ngx.now()

print("took: ", (e * 1000) - (s * 1000), " ms")
```

I get these results:
Current: `took: 57 ms`
     PR: `took: 7 ms`

Signed-off-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
@bungle bungle merged commit 582d5ac into master Jun 12, 2024
70 checks passed
@bungle bungle deleted the refactor/speed-up-strip branch June 12, 2024 08:44
@team-gateway-bot
Copy link
Collaborator

Successfully created cherry-pick PR for master:

locao pushed a commit that referenced this pull request Jun 21, 2024
### Summary

With simple microbenchmark:
```lua
ngx.update_time()
local s = ngx.now()
for i = 1, 100000 do
    local a = strip("           \t \ndogestr   \f\t\r ")
end
ngx.update_time()
local e = ngx.now()

print("took: ", (e * 1000) - (s * 1000), " ms")
```

I get these results:
Current: `took: 57 ms`
     PR: `took: 7 ms`

Signed-off-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
(cherry picked from commit 582d5ac)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee size/M skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants