-
Notifications
You must be signed in to change notification settings - Fork 11
/
Rakefile
61 lines (52 loc) · 1.4 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require "bundler/gem_tasks"
require "rake/testtask"
task default: :test
Rake::TestTask.new do |t|
t.libs << "test"
t.pattern = "test/**/*_test.rb"
t.warning = false # for daru
end
# TODO use benchmark-ips
def benchmark_user_recs(name, recommender)
ms = Benchmark.realtime do
recommender.user_ids.each do |user_id|
recommender.user_recs(user_id)
end
end
puts "%-8s %f" % [name, ms]
end
# TODO use benchmark-ips
def benchmark_item_recs(name, recommender)
ms = Benchmark.realtime do
recommender.item_ids.each do |item_id|
recommender.item_recs(item_id)
end
end
puts "%-8s %f" % [name, ms]
end
namespace :benchmark do
task :user_recs do
require "bundler/setup"
Bundler.require
require "benchmark"
data = Disco.load_movielens
recommender = Disco::Recommender.new
recommender.fit(data)
benchmark_user_recs("none", recommender)
recommender.optimize_user_recs
benchmark_user_recs("faiss", recommender)
end
task :item_recs do
require "bundler/setup"
Bundler.require
require "benchmark"
data = Disco.load_movielens
recommender = Disco::Recommender.new
recommender.fit(data)
benchmark_item_recs("none", recommender)
recommender.optimize_item_recs(library: "ngt")
benchmark_item_recs("ngt", recommender)
recommender.optimize_item_recs(library: "faiss")
benchmark_item_recs("faiss", recommender)
end
end