Skip to content

Instantly share code, notes, and snippets.

View casperisfine's full-sized avatar

Jean byroot Boussier casperisfine

View GitHub Profile
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'activerecord', github: 'rails/rails'
default: &default
adapter: mysql2
username: root
host: 192.168.64.72
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
default_animals: &default_animals
<<: *default
migrations_paths: db/animals_migrate
require 'zlib'
require 'benchmark'
require 'rubygems/package'
require 'rubygems/package/tar_reader'
duration = Benchmark.realtime do
tar = Gem::Package::TarReader.new(Zlib::GzipReader.open(ARGV.first))
tar.each { |_| }
end
require 'fileutils'
require 'lmdb'
require 'benchmark/ips'
PATH = __FILE__
MAX_SIZE = 134217728 # 128 MB
FileUtils.mkdir_p('/tmp/lmdb-bench')
@env = ::LMDB.new('/tmp/lmdb-bench', mapsize: MAX_SIZE, nometasync: true, nosync: true)
@database = @env.database('bootsnap', create: true)
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'activerecord'
gem 'benchmark-ips'
end
require 'benchmark/ips'
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "activerecord"
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
$ ruby /tmp/struct.rb
Warming up --------------------------------------
hash 1.450M i/100ms
naive 8.267k i/100ms
lazy-cached 68.069k i/100ms
explicit 415.985k i/100ms
Calculating -------------------------------------
hash 14.223M (± 3.4%) i/s - 71.047M in 5.001074s
# typed: false
# frozen_string_literal: true
# On MRI Symbols can be of two types: static or dynamic
#
# Static symbols are the ones explicitly referenced in the source code (`:foo`), and they're fake objects.
# Meaning they don't actually exists, they're just a special type of reference like integers. They use close to
# no memory, are particularly fast to compare and are not garbage collected.
#
# Dynamic symbols are symbols built using `String#to_sym` and that don't have an existing equivalent static symbol.
./configure -C --disable-install-doc --prefix=/opt/rubies/scratch