Skip to content

Instantly share code, notes, and snippets.

View kenchan's full-sized avatar
💭
😄

Kenichi Takahashi kenchan

💭
😄
View GitHub Profile
require 'benchmark'
puts "ruby-#{RUBY_VERSION}"
Benchmark.bm(10) do |x|
array = (10 ** 5).times.to_a
x.report 'sum' do |x|
array.sum {|i| i * 2 }
end
kbd = Keyboard.new
row1 = 0
row2 = 1
row3 = 2
row4 = 3
row5 = 4
row6 = 5
col1 = 11
col2 = 12

⭐ bundler/inline ⭐

👨 自己紹介

💎 Bundlerについて

require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'benchmark-ips'
end
require 'benchmark/ips'
Benchmark.ips do |x|
require 'benchmark/ips'
Benchmark.ips do |x|
x.report("each") do
s = 0
(10 ** 5).times.each do |i|
s += i
end
end
@kenchan
kenchan / output.txt
Created February 23, 2020 09:23
Ruby 2.3での階乗計算
Warming up --------------------------------------
** 70.304k i/100ms
my pow 27.298k i/100ms
Calculating -------------------------------------
** 1.633M (± 5.7%) i/s - 8.155M in 5.012777s
my pow 345.490k (± 3.6%) i/s - 1.747M in 5.063730s
Comparison:
**: 1632697.1 i/s
my pow: 345489.6 i/s - 4.73x slower
irb(main):013:0> require 'bigdecimal'
=> false
irb(main):014:0> 10.times.inject(0.0) {|i, _| i + 0.1 }.to_i
=> 0
irb(main):015:0> 10.times.inject(BigDecimal("0.0")) {|i, _| i + BigDecimal("0.1") }.to_i
=> 1
- https://www.hsbt.org/diary/no_comments.rdf
- https://diary.shu-cream.net/atom.xml
- https://june29.jp/index.xml
  • 下着 n 日分
  • 服 n 日分
  • パジャマ
  • バスタオル (ありそう)
  • タオル (ありそう)
  • ハブラシ
  • シェーバー
  • モバイルバッテリー
  • Apple Watch充電するやつ
  • 充電器
console.log("hi");