This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby 3.2.4 (2024-04-23 revision af471c0e01) [x86_64-linux] | |
Warming up -------------------------------------- | |
if / else 888.000 i/100ms | |
case / in 259.000 i/100ms | |
Calculating ------------------------------------- | |
if / else 8.856k (± 0.9%) i/s - 44.400k in 5.013974s | |
case / in 2.560k (± 3.0%) i/s - 12.950k in 5.064976s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/inline' | |
gemfile do | |
gem 'async-io', '~> 1.30' | |
end | |
require 'async' | |
require 'async/queue' | |
require 'async/io' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## bmplib.sh v1.0 | |
# | |
# Make your own BMP from scratch, no external dependencies. | |
# Useful in BitBar plugins. | |
# | |
# pixels=() # set pixels to empty or with background of same size | |
# # as will be declared in init_bmp | |
# curcol=(bb 66 44 aa) # set current color, BGRA, hex (%02x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'benchmark' | |
keys = ('aa'..'zz').map(&:to_sym) | |
Benchmark.bm do |b| | |
n = 10_000 | |
b.report('lazy initialize') do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gem install ronin-support | |
require 'ronin/support/network/tld' | |
def omit_each_char(tld) | |
return enum_for(__method__,tld) unless block_given? | |
tld.length.times do |i| | |
new_tld = tld.dup | |
new_tld[i] = '' | |
yield new_tld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'benchmark' | |
Benchmark.bm do |b| | |
n = 1_000_000 | |
value1 = 1 | |
value2 = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'benchmark' | |
class StaticDispatch | |
def dispatch | |
if rand > 0.5 | |
method1 | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org/' | |
gem 'sinatra', '~> 2.0' | |
gem 'webrick' | |
gem 'thin' | |
gem 'puma' | |
gem 'unicorn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'benchmark' | |
Benchmark.bm do |b| | |
n = 1_000_000 | |
array1 = [1,2,3,4,5,6] | |
array2 = [7,8,9,10,11,12,13,14] | |
array3 = [15,16,17,18,19,20] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TYPES: {:scope=>Namespace} | |
self::TYPES: {:scope=>Namespace::Mixin} |
NewerOlder