You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+31-1Lines changed: 31 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,37 @@ Keep that shape: end every `Benchmark.ips` block with `x.compare!`, keep the
39
39
default timing (no `Benchmark.ips(20)`, `x.time = ...` or `x.config(time: ...)`),
40
40
so every entry is measured the same way, and make sure
41
41
the file actually calls `Benchmark.ips` when it runs
42
-
(not only inside a method nothing calls). CI checks all three.
42
+
(not only inside a method nothing calls). CI checks these, and the naming below.
43
+
44
+
The method names say which report should win.
45
+
CI checks that exactly one report is named the winner and that it comes first.
46
+
Wrap every report in a method, so they all pay the same call cost.
47
+
Name them by rank and list the winner first.
48
+
The names grow outward from the line between fast and slow: the recommended side uses `fast`, then `faster`, then `fastest`; the other side uses `slow`, then `slower`, then `slowest`.
49
+
The names are relative: `slow` only means slower than `fast`.
50
+
When a ranking could look odd, say why in one line, like in `code/array/length-vs-size-vs-count.rb`:
51
+
52
+
```ruby
53
+
deffaster
54
+
ARRAY.length
55
+
end
56
+
57
+
# Array#size is an alias of Array#length, so these two should tie.
Copy file name to clipboardExpand all lines: README.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,7 @@ using an if statement: 15517955.2 i/s
134
134
String#constantize: 10556362.4 i/s - 1.47x slower
135
135
```
136
136
137
-
##### `raise` vs `E2MM#Raise` for raising (and defining) exceptions [code](code/general/raise-vs-e2mmap.rb)
137
+
##### `raise` vs `E2MM#Raise` for raising (and defining) exceptions [code](code/general/raise-vs-e2mmap.rb)[custom exception code](code/general/raise-custom-vs-e2mmap.rb)
138
138
139
139
Ruby's [Exception2MessageMapper module](http://ruby-doc.org/stdlib-2.2.0/libdoc/e2mmap/rdoc/index.html) allows one to define and raise exceptions with predefined messages.
0 commit comments