Skip to content

Commit ae5787f

Browse files
committed
Add micro benchmarks for TruffleRuby::ConcurrentMap
1 parent c50fa19 commit ae5787f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. This
2+
# code is released under a tri EPL/GPL/LGPL license. You can use it,
3+
# redistribute it and/or modify it under the terms of the:
4+
#
5+
# Eclipse Public License version 2.0, or
6+
# GNU General Public License version 2, or
7+
# GNU Lesser General Public License version 2.1.
8+
9+
if RUBY_ENGINE == 'truffleruby'
10+
map = TruffleRuby::ConcurrentMap.new
11+
10_000.times { |i| map[i] = i }
12+
map[:a] = 1
13+
14+
benchmark 'TruffleRuby::ConcurrentMap#[]' do
15+
map[:a]
16+
end
17+
18+
benchmark 'TruffleRuby::ConcurrentMap#[]=' do
19+
map[:set] = :value
20+
end
21+
22+
benchmark 'TruffleRuby::ConcurrentMap#each_pair' do
23+
map.each_pair { |k,v| k }
24+
end
25+
26+
benchmark 'TruffleRuby::ConcurrentMap#delete' do
27+
map[:to_delete] = true
28+
map.delete(:to_delete)
29+
end
30+
end

0 commit comments

Comments
 (0)