-
Notifications
You must be signed in to change notification settings - Fork 43
Performance
Nick Franken edited this page Dec 22, 2016
·
1 revision
with Postgres 9.4.5.0
- crystal 0.20.0
elapsed: 2.6528820
seconds
require "crecto"
class User < Crecto::Model
schema "users" do
field :name, String
field :things, Int32
field :stuff, Int32, virtual: true
field :nope, Float64
field :yep, Bool
field :some_date, Time
en
validates :name,
presence: true,
inclusion: { in: ["fridge", "mcridge"] },
format: { pattern: /[*a-zA-Z]/ },
length: { min: 2, max: 10 }
end
start_time = Time.now
10000.times do
user = User.new
user.name = "fridge"
changeset = User.changeset(user)
changeset = Crecto::Repo.insert(changeset)
end
end_time = Time.now
puts "elapsed: #{end_time - start_time}"
- ruby 2.3.1
- rails 5.0.0
elapsed: 14.624411
seconds
class User < ApplicationRecord
validates :name,
presence: true,
inclusion: { in: ["fridge", "mcridge"] },
format: { with: /[*a-zA-Z]/ },
length: { minimum: 2, maximum: 10 }
end
start_time = Time.now
10000.times do
u = User.new
u.name = "fridge"
u.save
end
end_time = Time.now
puts "elapsed: #{end_time-start_time}"