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'
gem 'activesupport', github: 'rails/rails'
gem 'benchmark-ips'
end
#!/usr/bin/env ruby
# frozen_string_literal: true
require "json"
File.open(ARGV.first).each_line do |line|
if line.include?('"value":')
obj = JSON.parse(line)
obj.delete("value")
puts JSON.dump(obj)
#!/bin/sh
set -eu
AGGRESSIVE=0
PARAMS=""
while [ "$#" -gt 0 ]; do
case "$1" in
--aggressive)
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'benchmark-ips'
gem 'xrb'
gem 'erb'
gem 'erubi'
$ rubocop --only Lint/UnusedMethodArgument unused.rb
Inspecting 1 file
W
Offenses:
unused.rb:1:9: W: [Correctable] Lint/UnusedMethodArgument: Unused method argument - bar. If it's necessary, use _ or _bar as an argument name to indicate that it won't be used. If it's unnecessary, remove it. You can also write as foo(*) if you want the method to accept any arguments but don't care about them.
def foo(bar, baz: 1)
^^^
unused.rb:1:14: W: Lint/UnusedMethodArgument: Unused method argument - baz. You can also write as foo(*) if you want the method to accept any arguments but don't care about them.
# syntax = docker/dockerfile:1
FROM ruby:3.3-slim
RUN apt-get update && apt-get install -y libjemalloc2
RUN echo "#!/bin/sh\nexport LD_PRELOAD=$(echo /usr/lib/*/libjemalloc.so.2)\nexec \"\$@\"" >> /exec \
&& chmod +x /exec
ENTRYPOINT ["/exec"]
data_received..................: 13 kB 314 B/s
data_sent......................: 11 kB 271 B/s
http_req_blocked...............: min=211µs avg=402.09µs med=380µs max=1.51ms p(95)=553.99µs p(99)=639.66µs p(99.99)=1.5ms
http_req_connecting............: min=172µs avg=348.67µs med=340µs max=567µs p(95)=463.8µs p(99)=545.5µs p(99.99)=566.83µs
http_req_duration..............: min=276.1ms avg=382.56ms med=308.34ms max=816.25ms p(95)=648.15ms p(99)=798.75ms p(99.99)=816.1ms
{ expected_response:true }...: min=276.1ms avg=382.56ms med=308.34ms max=816.25ms p(95)=648.15ms p(99)=798.75ms p(99.99)=816.1ms
http_req_failed................: 0.00% ✓ 0 ✗ 139
http_req_receiving.............: min=18µs avg=40.46µs med=39µs max=117µs p(95)=59µs p(99)=68.62µs p(99.99)=116.33µs
http_req_sending...............: min=17µs avg=29.12µs med=28µs max=65µs p(95)=40.09µs p(99)=47µs p(99.99)=64.75µs
$ bin/bench 5
Puma starting in single mode...
* Puma version: 6.4.1 (ruby 3.3.0-p0) ("The Eagle of Durango")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 87708
Testing with:
75.0% time spent waiting on CPU
25.0% time spent waiting on IO
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'benchmark-ips'
end
require 'benchmark/ips'
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "sqlite3"
gem "enumerable-statistics"
end
require "benchmark"