-
`str.count("\n")` is 1.3-170 times faster than `str.lines.count` or `str.each_line.count` (ref: https://serpapi.com/blog/lines-count-failed-deployments/). The speed difference grows with the lines cou…
-
While `define_method` indeed defines methods slighly faster than `module_eval`, I think it should be noted that _calling_ methods defined with `define_method` is slower than calling `module_eval` ones…
-
Examples:
```
hub clone -f user/repo
hub clone --fork user/repo
```
> Forks and then clones, adding both the upstream and own repos as reference. I prefer my own repo to be called `origin` (since th…
-
Crystal needs a general benchmarks suite for its standard library.
It should cover most of the core types, like String, Array, Hash, Enumerable, and its methods.
This will be very useful to see …
-
There's no loss in operating with either, but there are pros and cons we need to weight against each other:
## Representation
`Rational` has the benefit of describing infinitely repeating rational…
-
The type of benchmark ran in #9149 should be easy to repeat with as little manual work as possible.
Currently manual work that could be automated:
- Create a testnet fork with the correct number o…
-
I think a method should be added to `String` that returns the first character and should be a faster alternative to `[0]`. The strategy is to start an iteration through the string but stop at the firs…
-
If one is using keys that can be compared by identity, and if those keys are not already optimized (symbols are optimized, not sure what else is), using `compare_by_identity` can yield a 4x speedup.
…
-
Third approach?
```
require 'benchmark/ips'
ARRAY = [*1..100]
def faster
ARRAY.reverse_each { |x| break x if (x % 10).zero? }
end
def fast
ARRAY.reverse.detect { |x| (x % 10).zero? }
end
def …
-
Per the Ruby 2.4.0 docs:
> The current implementation of sort_by generates an array of tuples containing the original collection element and the mapped value. This makes sort_by fairly expensive wh…