script/perf_check.rb in alba-3.1.0 vs script/perf_check.rb in alba-3.2.0

- old
+ new

@@ -1,76 +1,9 @@ # Benchmark script to run varieties of JSON serializers # Fetch Alba from local, otherwise fetch latest from RubyGems # exit(status) -# --- Bundle dependencies --- - -require "bundler/inline" - -gemfile(true) do - source "https://rubygems.org" - git_source(:github) { |repo| "https://github.com/#{repo}.git" } - - gem "activerecord", "~> 6.1.3" - gem "alba", path: '../' - gem "benchmark-ips" - gem "blueprinter" - gem "jbuilder" - gem "multi_json" - gem "oj" - gem "sqlite3" -end - -# --- Test data model setup --- - -require "active_record" -require "oj" -require "sqlite3" -Oj.optimize_rails - -ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") - -ActiveRecord::Schema.define do - create_table :posts, force: true do |t| - t.string :body - end - - create_table :comments, force: true do |t| - t.integer :post_id - t.string :body - t.integer :commenter_id - end - - create_table :users, force: true do |t| - t.string :name - end -end - -class Post < ActiveRecord::Base - has_many :comments - has_many :commenters, through: :comments, class_name: 'User', source: :commenter - - def attributes - {id: nil, body: nil, commenter_names: commenter_names} - end - - def commenter_names - commenters.pluck(:name) - end -end - -class Comment < ActiveRecord::Base - belongs_to :post - belongs_to :commenter, class_name: 'User' - - def attributes - {id: nil, body: nil} - end -end - -class User < ActiveRecord::Base - has_many :comments -end +require_relative '../benchmark/prep' # --- Alba serializers --- require "alba"