Created
January 7, 2015 08:28
-
-
Save aaronjensen/46bff917f3dff3a3e851 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ready "codepoints" do | |
before do | |
@str = "a" * 30 + "x" | |
end | |
go "index many matches" do | |
index = @str.index("a") | |
while index | |
index = @str.index("a", index + 1) | |
end | |
end | |
go "codepoints many matches" do | |
points = @str.codepoints | |
i = 0 | |
length = points.length | |
while i < length | |
points[i] == 97 | |
i += 1 | |
end | |
end | |
go "index one match" do | |
index = @str.index("x") | |
while index | |
index = @str.index("x", index + 1) | |
end | |
end | |
go "codepoints one match" do | |
points = @str.codepoints | |
i = 0 | |
length = points.length | |
while i < length | |
points[i] == 120 | |
i += 1 | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
codepoints index many matches | |
Baseline: | X------| | |
Current: | X------| | |
0 4.969 us | |
codepoints codepoints many matches | |
Baseline: | X---------- | | |
Current: | X--------| | |
0 1.837 us | |
codepoints index one match | |
Baseline: | X------------| | |
Current: | X-------- | | |
0 337.891 ns | |
codepoints codepoints one match | |
Baseline: | X---| | |
Current: | X----| | |
0 1.708 us |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment