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

CamoFilter: use String#unpack to hexencode URLs #256

Merged
merged 1 commit into from Apr 6, 2019

Conversation

glaszig
Copy link
Contributor

@glaszig glaszig commented Jun 20, 2016

ruby's benchmark with 100_000 iterations report some performance
improvement (up to 80x on my machine) over iterating over each byte.

https://gist.github.com/glaszig/9d1975b1821a799c5db5957c4cff1539

Rehearsal -------------------------------------------------
interpolation   4.480000   0.010000   4.490000 (  4.481051)
String#unpack   0.100000   0.000000   0.100000 (  0.111963)
---------------------------------------- total: 4.590000sec

                    user     system      total        real
interpolation   4.490000   0.010000   4.500000 (  4.501468)
String#unpack   0.100000   0.000000   0.100000 (  0.109444)

        input: https://www.example.com/path/to/image.png
interpolation: 68747470733a2f2f7777772e6578616d706c652e636f6d2f706174682f746f2f696d6167652e706e67
String#unpack: 68747470733a2f2f7777772e6578616d706c652e636f6d2f706174682f746f2f696d6167652e706e67

@JuanitoFatas
Copy link
Contributor

LGTM, @jch ?

@jch
Copy link
Contributor

jch commented Jun 28, 2016

Wow, this is great. Sorry for the late response, I was out on vacation in the woods. I'll queue this up for some testing.

@glaszig
Copy link
Contributor Author

glaszig commented Jan 28, 2017

any issue with this? can we get this off our plates?

@jch
Copy link
Contributor

jch commented Feb 8, 2017

Sorry, work's been busy, so still haven't had time to properly test this on a live production app.

ruby's benchmark with 100_000 iterations report some  performance
improvement (up to 80x on my machine) over iterating over each byte.

https://gist.github.com/glaszig/9d1975b1821a799c5db5957c4cff1539
@glaszig
Copy link
Contributor Author

glaszig commented Apr 6, 2019

rebased onto master. on a newer macbook (2015, the results above are from a mbp 2010), this patch is still orders of magnitude faster. lgtfm?

Rehearsal -------------------------------------------------
interpolation   3.069502   0.002232   3.071734 (  3.073401)
String#unpack   0.054645   0.000613   0.055258 (  0.055467)
---------------------------------------- total: 3.126992sec

                    user     system      total        real
interpolation   3.036294   0.001228   3.037522 (  3.038139)
String#unpack   0.053609   0.000240   0.053849 (  0.053939)

        input: https://www.example.com/path/to/image.png
interpolation: 68747470733a2f2f7777772e6578616d706c652e636f6d2f706174682f746f2f696d6167652e706e67
String#unpack: 68747470733a2f2f7777772e6578616d706c652e636f6d2f706174682f746f2f696d6167652e706e67

@gjtorikian
Copy link
Owner

Can't argue with numbers, thanks. Bumping this out as 2.11 now.

@gjtorikian gjtorikian merged commit 0901ea7 into gjtorikian:master Apr 6, 2019
@glaszig glaszig deleted the camo-filter-performance branch April 8, 2019 22:25
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.

None yet

4 participants