Créer une petite API rails permettant de créer des capteurs (sensor) et leur attribuer des valeurs dans le temps
CREATE TABLE sensors(
id integer primary_key,
name varchar(30) NOT NULL
$ git checkout master
$ bundle exec ruby test_jsonapi.rb
Warming up --------------------------------------
10_000 1.000 i/100ms
Calculating -------------------------------------
10_000 9.795 (±10.2%) i/s - 49.000 in 5.023501s
$ git checkout optimize-resource-processor
require 'active_support/all' | |
require 'benchmark' | |
# Bench try vs &. on nil case | |
foo = nil | |
class Bar | |
def lala | |
# does nothing |
# Other syntax without patch | |
STUDENT_LEVELS = { | |
freshman: Student::Underclassman, | |
sophomore: Student::Underclassman, | |
junior: Student::Upperclassman, | |
senior: Student::Upperclassman, | |
graduate: Student::Graduate | |
}.tap { |h| h.default = Student::Unregistered } | |