Skip to content

Commit 8bb9e20

Browse files
committed
fixup benchmarks
1 parent b586a24 commit 8bb9e20

File tree

6 files changed

+83
-59
lines changed

6 files changed

+83
-59
lines changed

benchmarks/sequence_set-and.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ prelude: |
33
require "yaml"
44
require "net/imap"
55
6-
INPUT_COUNT = Integer ENV.fetch("SEQSET_LHS_SIZE", 1000)
7-
MAX_INPUT = Integer ENV.fetch("SEQSET_LHS_MAX", 1400)
6+
INPUT_COUNT = Integer ENV.fetch("PROFILE_INPUT_COUNT", 1000)
7+
MAX_INPUT = Integer ENV.fetch("PROFILE_MAX_INPUT", 1400)
8+
WARMUP_RUNS = Integer ENV.fetch("PROFILE_WARMUP_RUNS", 200)
89
910
SETS = Array.new(1000) {
1011
Net::IMAP::SequenceSet[Array.new(INPUT_COUNT) { rand(1..MAX_INPUT) }]
@@ -49,19 +50,17 @@ prelude: |
4950
end
5051
end
5152
52-
# warmup for YJIT
53-
if RubyVM::YJIT.enabled?
54-
300.times do
55-
lhs, rhs = sets
56-
lhs | rhs
57-
lhs & rhs
58-
lhs - rhs
59-
lhs ^ rhs
60-
~lhs
61-
lhs.and0 rhs
62-
lhs.and1 rhs
63-
lhs.and2 rhs
64-
end
53+
# warmup (esp. for JIT)
54+
WARMUP_RUNS.times do
55+
lhs, rhs = sets
56+
lhs | rhs
57+
lhs & rhs
58+
lhs - rhs
59+
lhs ^ rhs
60+
~lhs
61+
lhs.and0 rhs
62+
lhs.and1 rhs
63+
lhs.and2 rhs
6564
end
6665
6766
benchmark:

benchmarks/sequence_set-not.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ prelude: |
33
require "yaml"
44
require "net/imap"
55
6-
INPUT_COUNT = Integer ENV.fetch("SEQSET_LHS_SIZE", 1000)
7-
MAX_INPUT = Integer ENV.fetch("SEQSET_LHS_MAX", 1400)
6+
INPUT_COUNT = Integer ENV.fetch("PROFILE_INPUT_COUNT", 1000)
7+
MAX_INPUT = Integer ENV.fetch("PROFILE_MAX_INPUT", 1400)
8+
WARMUP_RUNS = Integer ENV.fetch("PROFILE_WARMUP_RUNS", 200)
89
910
SETS = Array.new(1000) {
1011
Net::IMAP::SequenceSet[Array.new(INPUT_COUNT) { rand(1..MAX_INPUT) }]
@@ -66,15 +67,13 @@ prelude: |
6667
end
6768
end
6869
69-
# warmup for YJIT
70-
if RubyVM::YJIT.enabled?
71-
300.times do
72-
~SETS.sample
73-
SETS.sample.orig_not
74-
SETS.sample.enum_not
75-
SETS.sample.dup.orig_not!
76-
SETS.sample.dup.enum_not!
77-
end
70+
# warmup (esp. for JIT)
71+
WARMUP_RUNS.times do
72+
~SETS.sample
73+
SETS.sample.orig_not
74+
SETS.sample.enum_not
75+
SETS.sample.dup.orig_not!
76+
SETS.sample.dup.enum_not!
7877
end
7978
8079
benchmark:

benchmarks/sequence_set-ops.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ prelude: |
33
require "yaml"
44
require "net/imap"
55
6-
INPUT_COUNT = Integer ENV.fetch("SEQSET_LHS_SIZE", 1000)
7-
MAX_INPUT = Integer ENV.fetch("SEQSET_LHS_MAX", 1400)
6+
INPUT_COUNT = Integer ENV.fetch("PROFILE_INPUT_COUNT", 1000)
7+
MAX_INPUT = Integer ENV.fetch("PROFILE_MAX_INPUT", 1400)
8+
WARMUP_RUNS = Integer ENV.fetch("PROFILE_WARMUP_RUNS", 200)
89
910
SETS = Array.new(1000) {
1011
Net::IMAP::SequenceSet[Array.new(INPUT_COUNT) { rand(1..MAX_INPUT) }]
@@ -15,16 +16,14 @@ prelude: |
1516
[l.dup, r]
1617
end
1718
18-
# warmup for YJIT
19-
if RubyVM::YJIT.enabled?
20-
200.times do
21-
lhs, rhs = sets
22-
lhs | rhs
23-
lhs & rhs
24-
lhs - rhs
25-
lhs ^ rhs
26-
~lhs
27-
end
19+
# warmup (esp. for JIT)
20+
200.times do
21+
lhs, rhs = sets
22+
lhs | rhs
23+
lhs & rhs
24+
lhs - rhs
25+
lhs ^ rhs
26+
~lhs
2827
end
2928
3029
benchmark:
@@ -33,7 +32,3 @@ benchmark:
3332
difference: l, r = sets; l - r
3433
xor: l, r = sets; l ^ r
3534
complement: l, _ = sets; ~l
36-
37-
intersect?: l, r = sets; l.intersect? r
38-
disjoint?: l, r = sets; l.disjoint? r
39-
cover?: l, r = sets; l.cover? r
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
prelude: |
3+
require "yaml"
4+
require "net/imap"
5+
6+
INPUT_COUNT = Integer ENV.fetch("PROFILE_INPUT_COUNT", 1000)
7+
MAX_INPUT = Integer ENV.fetch("PROFILE_MAX_INPUT", 1400)
8+
WARMUP_RUNS = Integer ENV.fetch("PROFILE_WARMUP_RUNS", 200)
9+
10+
SETS = Array.new(1000) {
11+
Net::IMAP::SequenceSet[Array.new(INPUT_COUNT) { rand(1..MAX_INPUT) }]
12+
}
13+
14+
def sets
15+
l, r = SETS.sample(2)
16+
[l.dup, r]
17+
end
18+
19+
# warmup (esp. for JIT)
20+
WARMUP_RUNS.times do
21+
lhs, rhs = sets
22+
lhs | rhs
23+
lhs & rhs
24+
lhs - rhs
25+
lhs ^ rhs
26+
~lhs
27+
end
28+
29+
benchmark:
30+
intersect?: l, r = sets; l.intersect? r
31+
disjoint?: l, r = sets; l.disjoint? r
32+
cover?: l, r = sets; l.cover? r

benchmarks/sequence_set-aget.yml renamed to benchmarks/sequence_set-slice.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ prelude: |
2727
2828
# warmup
2929
init n: 100, d: 2
30-
100.times do
30+
200.times do
3131
set[idx]
3232
set[range]
3333
set[idx, len]

benchmarks/sequence_set-xor.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ prelude: |
33
require "yaml"
44
require "net/imap"
55
6-
INPUT_COUNT = Integer ENV.fetch("SEQSET_LHS_SIZE", 1000)
7-
MAX_INPUT = Integer ENV.fetch("SEQSET_LHS_MAX", 1400)
6+
INPUT_COUNT = Integer ENV.fetch("PROFILE_INPUT_COUNT", 1000)
7+
MAX_INPUT = Integer ENV.fetch("PROFILE_MAX_INPUT", 1400)
8+
WARMUP_RUNS = Integer ENV.fetch("PROFILE_WARMUP_RUNS", 200)
89
910
SETS = Array.new(1000) {
1011
Net::IMAP::SequenceSet[Array.new(INPUT_COUNT) { rand(1..MAX_INPUT) }]
@@ -54,20 +55,18 @@ prelude: |
5455
end
5556
end
5657
57-
# warmup for YJIT
58-
if RubyVM::YJIT.enabled?
59-
300.times do
60-
lhs, rhs = sets
61-
lhs | rhs
62-
lhs & rhs
63-
lhs - rhs
64-
lhs ^ rhs
65-
~lhs
66-
lhs.xor0 rhs
67-
lhs.xor1 rhs
68-
lhs.xor2 rhs
69-
lhs.xor3 rhs
70-
end
58+
# warmup (esp. for JIT)
59+
WARMUP_RUNS.times do
60+
lhs, rhs = sets
61+
lhs | rhs
62+
lhs & rhs
63+
lhs - rhs
64+
lhs ^ rhs
65+
~lhs
66+
lhs.xor0 rhs
67+
lhs.xor1 rhs
68+
lhs.xor2 rhs
69+
lhs.xor3 rhs
7170
end
7271
7372
benchmark:

0 commit comments

Comments
 (0)