Skip to content

Instantly share code, notes, and snippets.

Benchmarking ActiveRecord vs Perpetuity::Postgres

Running through a set of common CRUD operations. Each object on both ORMs uses a single model containing 3 attributes: a String, a Fixnum, and a Time. Each benchmark operates on 5000 objects.

Instantiating 5000 objects

           user     system      total        real
AR     0.230000   0.010000   0.240000 (  0.240430)
PORO 0.000000 0.000000 0.000000 ( 0.001539)
@mileer
mileer / 42-things.md
Last active August 29, 2015 14:21 — forked from PWSdelta/42-things.md
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
context "GET index" do
#context "POST create" do
#context "GET show" do
#context "PATCH update" do (or PUT update)
#context "DELETE destroy" do
#context "GET new" do
#
# At CoverHound, we use conditional validations all over the form. However, there is no proper way to do
# this in Rails. Instead, we can provide an array of attributes (validated_fields attribute)
# and ensure they are the only ones to get validated.
#
module ConditionalValidations
attr_accessor :validated_fields
def field_is_required?(field)
@mileer
mileer / README.md
Last active August 29, 2015 14:20 — forked from hofmannsven/README.md
<div class="container">
<h1>10-колоночный шаблон с вложенностью блоков</h1>
<!-- Column 1 -->
<div class="column column_1">
<h2>Колонка 1</h2>
</div>
<!-- Column 2 -->
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
$breakpoints: (
'small' : '( min-width: 767px )',
'medium' : '( min-width: 992px )',
'large' : '( min-width: 1200px )',
'complex': '( min-width: 767) and ( max-width: 992px)',
<div class="color alpha-color-1"><span>alpha-color-1</span></div>
<div class="color alpha-color-2"><span>alpha-color-2</span></div>
<div class="color alpha-color-3"><span>alpha-color-3</span></div>
<div class="color alpha-color-4"><span>alpha-color-4</span></div>
<div class="color alpha-color-5"><span>alpha-color-5</span></div>
<div class="clear"></div>
<div class="color beta-color-1"><span>beta-color-1</span></div>
<div class="color beta-color-2"><span>beta-color-2</span></div>
RAILS_ENV=production rake db:setup
# produces the error below.....hmmm.....it's a no-worky
psql:/yourprojectpath/yourproject/db/structure.sql:29: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory
# hstore postgresql extension needs to be installed, so....
sudo apt-get install postgresql-contrib
# now your extension should be available to enable so log in with psql
psql -d yourproject_production -U yourdbuser -W