Skip to content

Commit d1003ff

Browse files
committed
Adds benchmarking
1 parent a4e94b9 commit d1003ff

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

benchmarks/sc2_profile_parsing.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
2+
3+
require 'benchmark'
4+
require 'bnet_scraper'
5+
6+
@@bnet_accounts = [
7+
{ bnet_id: 2377239, name: 'Demon', race: 'protoss' },
8+
{ bnet_id: 2035618, name: 'Mykaelos', race: 'random' },
9+
{ bnet_id: 1826063, name: 'Fyrefly', race: 'zerg' },
10+
{ bnet_id: 2539344, name: 'Cadwallion', race: 'terran' }
11+
]
12+
13+
def parse_random_account
14+
account = @@bnet_accounts[rand(@@bnet_accounts.size)]
15+
BnetScraper::Starcraft2::ProfileScraper.new(account[:bnet_id], account[:name]).scrape
16+
end
17+
18+
Benchmark.bmbm(7) do |x|
19+
x.report('1') { parse_random_account }
20+
x.report('5') { 5.times { parse_random_account } }
21+
x.report('10') { 10.times { parse_random_account } }
22+
x.report('25') { 25.times { parse_random_account } }
23+
x.report('50') { 50.times { parse_random_account } }
24+
end

0 commit comments

Comments
 (0)