Skip to content

Instantly share code, notes, and snippets.

View alchimere's full-sized avatar

Yann Berthou (firetonton) alchimere

View GitHub Profile

Test rails QOS

Créer une petite API rails permettant de créer des capteurs (sensor) et leur attribuer des valeurs dans le temps

Base de donnée:

CREATE TABLE sensors(
  id integer primary_key,
 name varchar(30) NOT NULL
@alchimere
alchimere / bench_jsonapi-render-patch.md
Last active September 9, 2019 20:10
Benchmark jsonapi-render patch

$ 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

@alchimere
alchimere / bench_try.rb
Last active January 20, 2021 11:34
Bench try vs &.
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 }