Each one is original first, then OJ.
rake benchmarks:single_object_with_render:
#original
Calculating -------------------------------------
jbuilder 30 i/100ms
active_model_serializers
2015-02-02 15:19:27.559+0000 INFO [o.n.s.CommunityNeoServer]: Setting startup timeout to: 120000ms based on 120000 | |
2015-02-02 15:19:27.671+0000 INFO [o.n.k.InternalAbstractGraphDatabase]: No locking implementation specified, defaulting to 'community' | |
2015-02-02 15:19:27.776+0000 INFO [o.n.k.i.DiagnosticsManager]: --- INITIALIZED diagnostics START --- | |
2015-02-02 15:19:27.778+0000 INFO [o.n.k.i.DiagnosticsManager]: Neo4j Kernel properties: | |
2015-02-02 15:19:27.783+0000 INFO [o.n.k.i.DiagnosticsManager]: store_dir=/Users/cgrigg/RailsCrap/neotest/db/neo4j/development/data/graph.db | |
2015-02-02 15:19:27.783+0000 INFO [o.n.k.i.DiagnosticsManager]: remote_shell_enabled=true | |
2015-02-02 15:19:27.784+0000 INFO [o.n.k.i.DiagnosticsManager]: Diagnostics providers: | |
2015-02-02 15:19:27.784+0000 INFO [o.n.k.i.DiagnosticsManager]: org.neo4j.kernel.configuration.Config | |
2015-02-02 15:19:27.784+0000 INFO [o.n.k.i.DiagnosticsManager]: org.neo4j.kernel.info.DiagnosticsManager | |
2015-02-02 15:19:27.784+0000 INFO [o.n.k.i.Diag |
class Post < ActiveRecord::Base | |
extend AgfScrape | |
default_scope { order(:id) } | |
def self.url | |
"http://www.acousticguitarforum.com/forums/forumdisplay.php"\ | |
"?f=17&pp=200&sort=lastpost&order=desc&daysprune=200" | |
end | |
def self.forum |
require 'benchmark/ips' | |
Benchmark.ips do |x| | |
x.config(warmup: 1, time: 5) | |
def test1 | |
a = [:foo, :bar, :baz, :omg, :wtf, :gtfo] | |
a.map(&:to_s) | |
end |
Each one is original first, then OJ.
rake benchmarks:single_object_with_render:
#original
Calculating -------------------------------------
jbuilder 30 i/100ms
active_model_serializers
class Movie | |
include Neo4j::ActiveNode | |
id_property :title | |
has_many :in, :actors, model_class: :Person, rel_class: Engagement | |
end | |
class Engagement | |
include Neo4j::ActiveRel | |
from_class Person | |
to_class Movie |
[ | |
{ | |
"columns": [ | |
"r" | |
], | |
"data": [ | |
{ | |
"row": [ | |
{ | |
"_classname": "StudentLesson" |
# /u/zaclacgit on Reddit posted a topic the other day asking for thoughts on his exercise of | |
# recreating some basic enumerable methods. I gave him some tips on refactoring one method in particular | |
# and a few days later, he asked me to elaborate. I thought the easiest way might be to go through each | |
# step of the refactor and I'd get a nice blog post out of it in the process. | |
# To use this, start by commenting out each `my_inject` definition except the first. As you encounter | |
# new ones, uncomment them. Save this file as `refactor.rb` in the folder of your choice, ensure you have | |
# the rspec gem installed and run `rspec refactor.rb` from CLI to execute. | |
# Before we write a line of code, we're going to write specs based off of the simple comparisons |
ORIGINAL | |
2.1.2 :002 > Benchmark.ips do |x| | |
2.1.2 :003 > x.config(:time => 5, :warmup => 2) | |
2.1.2 :004?> x.time = 10 | |
2.1.2 :005?> x.warmup = 2 | |
2.1.2 :006?> x.report("query") { Student.limit(900).each { |s| } } | |
2.1.2 :007?> end | |
Calculating ------------------------------------- | |
query CYPHER 26ms MATCH (result:`Student`) RETURN result LIMIT 900 |
def my_inject(initial = nil, sym = nil) | |
memo, starter = initial, self if initial && block_given? | |
memo, starter = self[0], self[1..-1] if initial.nil? || !block_given? | |
starter.push(initial) unless sym.nil? || block_given? | |
starter.my_each do |x| | |
if sym | |
memo = memo.send(sym, x) | |
elsif block_given? | |
memo = yield(memo,x) | |
else |
[Student, Lesson, Teacher, Exam].each{|c| c.destroy_all } | |
ss101 = Lesson.create(subject: 'Social Studies', level: 101) | |
ss102 = Lesson.create(subject: 'Social Studies', level: 102) | |
math101 = Lesson.create(subject: 'Math', level: 101) | |
math201 = Lesson.create(subject: 'Math', level: 201) | |
geo103 = Lesson.create(subject: 'Geography', level: 103) | |
sandra = Student.create(name: 'Sandra', age: 16) | |
danny = Student.create(name: 'Danny', age: 15) |