forked from ankane/groupdate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
59 lines (46 loc) · 1.41 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
require "bundler/gem_tasks"
require "rake/testtask"
ADAPTERS = %w(postgresql mysql sqlite enumerable redshift)
ADAPTERS.each do |adapter|
namespace :test do
task("env:#{adapter}") { ENV["ADAPTER"] = adapter }
Rake::TestTask.new(adapter => "env:#{adapter}") do |t|
t.description = "Run tests for #{adapter}"
t.libs << "test"
# TODO permit works for enumerable, just need to make tests work
exclude = adapter == "enumerable" ? /database|multiple_group|permit/ : /enumerable/
t.test_files = FileList["test/**/*_test.rb"].exclude(exclude)
end
end
end
desc "Run all adapter tests besides redshift"
task :test do
ADAPTERS.each do |adapter|
next if adapter == "redshift"
Rake::Task["test:#{adapter}"].invoke
end
end
task default: :test
desc "Profile call"
task :profile do
require "active_record"
require "sqlite3"
require "groupdate"
require "ruby-prof"
# RubyProf.measure_mode = RubyProf::ALLOCATIONS
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
ActiveRecord::Migration.create_table :users, force: true do |t|
t.timestamp :created_at
end
class User < ActiveRecord::Base
end
now = Time.now
10000.times do |n|
User.create!(created_at: now - n.days)
end
result = RubyProf.profile do
User.group_by_day(:created_at).count
end
printer = RubyProf::GraphPrinter.new(result)
printer.print(STDOUT, {})
end