Last active
August 29, 2015 14:03
-
-
Save alco/aea769ba02dce93de29f 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
# master | |
StringSlice.slice left half: 100 20628.67 µs/op | |
StringSlice.slice right half: 50 33514.14 µs/op | |
StringSlice.slice almost all: 50 40865.84 µs/op | |
StringSlice.slice -1: 50 63981.30 µs/op | |
# PR | |
StringSlice.slice -1: 10000000 0.60 µs/op | |
StringSlice.slice left half: 100 15272.15 µs/op | |
StringSlice.slice right half: 50 29207.42 µs/op | |
StringSlice.slice almost all: 50 30960.10 µs/op | |
# speedup | |
# This is the ratio of (PR execution time) / (master execution time) | |
StringSlice:slice -1: 0.0 | |
StringSlice:slice left half: 0.76 | |
StringSlice:slice almost all: 0.77 | |
StringSlice:slice right half: 0.88 |
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
Benchfella.start duration: 1.0, format: :machine, verbose: true | |
defmodule StringSlice do | |
use Benchfella | |
@str String.duplicate("hello world", 10000) | |
@len String.length(@str) | |
bench "slice left half" do | |
String.slice(@str, 0, div(@len,2)) | |
end | |
bench "slice right half" do | |
String.slice(@str, div(@len,2), @len-1) | |
end | |
bench "slice almost all" do | |
String.slice(@str, 1, @len-1) | |
end | |
bench "slice -1" do | |
String.slice(@str, 1..-1) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment