source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | bundler/benchmarks/bm_bundle_install_rails.rb | Ruby | mit | 49 | master | 518 | require_relative 'support/benchmark_bundler.rb'
require 'bundler/cli'
# Fixed Nokogiri version because latest version 1.6.8 fails to install
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails'
gem 'nokogiri', '1.6.7.2'
GEMFILE... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | bundler/benchmarks/resolve_issue3687.rb | Ruby | mit | 49 | master | 30,194 | require_relative 'support/benchmark_bundler.rb'
gemfile = proc do
source 'http://rubygems.org'
gem 'rails', '4.1.1'
gem 'protected_attributes'
gem 'puma', '~> 2.6'
gem 'redis', '~> 3.0.7'
gem 'newrelic_rpm'
gem 'newrelic_resque_agent'
gem 'mysql2'
gem 'by_star'
gem 'resque-scheduler'
gem 'resque... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | bundler/benchmarks/bm_bundle_lock_gem.rb | Ruby | mit | 49 | master | 442 | require_relative 'support/benchmark_bundler.rb'
require 'bundler/cli'
noop_gem = Pathname(__FILE__).expand_path + '../gems/noop-gem'
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails'
gem 'noop-gem', path: '#{noop_gem}'
GEMFI... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | bundler/benchmarks/bm_bundle_outdated_rails.rb | Ruby | mit | 49 | master | 452 | require_relative 'support/benchmark_bundler.rb'
require 'bundler/cli'
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '5.0.0.rc1'
gem 'nokogiri', '1.6.7.0'
GEMFILE
system("bundle install --quiet")
system("bundle o... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | bundler/benchmarks/bm_bundle_exec_gem.rb | Ruby | mit | 49 | master | 465 | require_relative 'support/benchmark_bundler.rb'
require 'bundler/cli'
noop_gem = Pathname(__FILE__).expand_path + '../gems/noop-gem'
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails'
gem 'noop-gem', path: '#{noop_gem}'
GEMFI... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | bundler/benchmarks/bm_parse_lockfile.rb | Ruby | mit | 49 | master | 8,166 | require_relative 'support/benchmark_bundler.rb'
data = DATA.read
Benchmark.do_benchmark('parse lockfile', time: 5, warmup: 2) do
Bundler::LockfileParser.new(data)
end
__END__
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.1)
actionpack (= 4.2.1)
actionview (= 4.2.1)
activejob (... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | bundler/benchmarks/bm_bundle_exec_binary.rb | Ruby | mit | 49 | master | 464 | require_relative 'support/benchmark_bundler.rb'
require 'bundler/cli'
noop_gem = Pathname(__FILE__).expand_path + '../gems/noop-gem'
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails'
gem 'noop-gem', path: '#{noop_gem}'
GEMFI... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | bundler/benchmarks/gems/noop-gem/noop-gem.gemspec | Ruby | mit | 49 | master | 666 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'noop/gem/version'
Gem::Specification.new do |spec|
spec.name = "noop-gem"
spec.version = Noop::Gem::VERSION
spec.authors = ["Samuel E. Giddins"]
spec.email = ... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | bundler/benchmarks/support/benchmark_bundler.rb | Ruby | mit | 49 | master | 2,278 | require 'bundler'
require 'benchmark/ips'
require 'json'
require 'tempfile'
ENV['BUNDLE_GEMFILE'] = 'Gemfile'
rubygems = Bundler.rubygems
def rubygems.validate(spec); end
# Bundler.ui = Bundler::UI::Shell.new
module Benchmark
module Bundler
module Resolver
def resolve_definition(label, gemfile, lockfile... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/Gemfile | Ruby | mit | 49 | master | 527 | source 'https://rubygems.org'
module ::Kernel
def sequel_master?
ENV["SEQUEL_MASTER"] == '1'
end
def mysql2_prepared_statements?
ENV["MYSQL2_PREPARED_STATEMENTS"] == '1'
end
end
if sequel_master?
gem 'sequel', github: 'jeremyevans/sequel', branch: 'master'
else
gem 'sequel', path: '/sequel'
end
... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_save.rb | Ruby | mit | 49 | master | 502 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_save_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model
self.raise_on_save_failure = true
plugin :timestamps, update_on_create: true
end
attributes = {
name: "Lorem ipsum ... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_scope_all_with_default_scope.rb | Ruby | mit | 49 | master | 534 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_with_default_scope_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model
dataset_module do
def only_admins
where(:admin => true)
end
end
set_dataset(self.only_a... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_finders_first.rb | Ruby | mit | 49 | master | 370 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_finders_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model; end
Benchmark.sequel("sequel/#{db_adapter}_finders_first", time: 5) do
user = User.select(:name, :email).first
st... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_create_string_columns.rb | Ruby | mit | 49 | master | 493 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_create_string_columns_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model
self.raise_on_save_failure = true
plugin :timestamps, update_on_create: true
end
attributes = {}
25... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_scope_all_over_select.rb | Ruby | mit | 49 | master | 452 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_scope_all_setup.rb"
Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model; end
Benchmark.sequel("sequel/#{db_adapter}_scope_all_over_select", time: 5) do
str = ""
User.all.each do |user|
... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_scope_where_over_select.rb | Ruby | mit | 49 | master | 521 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_scope_where_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model; end
Benchmark.sequel("sequel/#{db_adapter}_scope_where_over_select", time: 5) do
str = ""
User
.where(nam... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_finders_find_by_attributes.rb | Ruby | mit | 49 | master | 402 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_finders_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model; end
Benchmark.sequel("sequel/#{db_adapter}_finders_find_by_attributes", time: 5) do
user = User.select(:name, :emai... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_destroy.rb | Ruby | mit | 49 | master | 569 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_destroy_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model
self.raise_on_save_failure = true
plugin :timestamps, update_on_create: true
end
attributes = {
name: "Lorem ips... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_discourse.rb | Ruby | mit | 49 | master | 2,096 | require "bundler/setup"
require "sequel"
require_relative "support/benchmark_sequel"
db_setup script: "bm_discourse_setup.rb"
DB = Sequel.connect(ENV.fetch("DATABASE_URL"))
class User < Sequel::Model
one_to_many :topic_users
one_to_many :category_users
one_to_many :topics
end
class Topic < Sequel::Model
on... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_finders_first_over_select.rb | Ruby | mit | 49 | master | 360 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_finders_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model; end
Benchmark.sequel("sequel/#{db_adapter}_finders_first_over_select", time: 5) do
user = User.first
str = "name:... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_validations_valid.rb | Ruby | mit | 49 | master | 854 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_validations_valid_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class Post < Sequel::Model
plugin :validation_helpers
def validate
super
validates_presence :title
validates_unique :seq... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_scope_where.rb | Ruby | mit | 49 | master | 536 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_scope_where_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model; end
Benchmark.sequel("sequel/#{db_adapter}_scope_where", time: 5) do
str = ""
User
.select(:name, :email)... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_validations_invalid.rb | Ruby | mit | 49 | master | 845 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_validations_invalid_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class Post < Sequel::Model
plugin :validation_helpers
def validate
super
validates_presence :title
validates_unique :s... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/driver.rb | Ruby | mit | 49 | master | 5,421 | #
# Sequel Benchmark driver
#
require 'bundler/setup'
require 'net/http'
require 'json'
require 'pathname'
require 'optparse'
require 'active_model'
require 'digest'
RAW_URL = 'https://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/sequel/benchmarks/'
DATABASE_URLS = {
psql: "postgres://postgres@postg... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_scope_all.rb | Ruby | mit | 49 | master | 486 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_scope_all_setup.rb"
Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model; end
Benchmark.sequel("sequel/#{db_adapter}_scope_all", time: 5) do
str = ""
User.select(:name, :email, :approved, :a... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_finders_find_by_attributes_over_select.rb | Ruby | mit | 49 | master | 397 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_finders_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model; end
Benchmark.sequel("sequel/#{db_adapter}_finders_find_by_attributes_over_select", time: 5) do
user = User.find(em... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/bm_sequel_scope_all_with_default_scope_over_select.rb | Ruby | mit | 49 | master | 528 | require 'bundler/setup'
require 'sequel'
require_relative 'support/benchmark_sequel'
db_setup script: "bm_with_default_scope_setup.rb"
DB = Sequel.connect(ENV.fetch('DATABASE_URL'))
class User < Sequel::Model
dataset_module do
def only_admins
where(:admin => true)
end
end
set_dataset(self.only_a... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | sequel/benchmarks/support/benchmark_sequel.rb | Ruby | mit | 49 | master | 392 | require_relative '../../../support/benchmark_runner'
require_relative '../../../support/helpers'
module Benchmark
module Sequel
def sequel(label=nil, version: ::Sequel.version.to_s, time:, disable_gc: true, warmup: 3, &block)
Benchmark::Runner.run(label, version: version, time: time, disable_gc: disable_gc... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | optcarrot_benchmarks/driver.rb | Ruby | mit | 49 | master | 750 | require 'digest'
require_relative 'optcarrot/lib/optcarrot'
ENV['BENCHMARK_TYPE_SCRIPT_URL'] = 'https://raw.githubusercontent.com/mame/optcarrot/master/lib/optcarrot/nes.rb'
ENV['BENCHMARK_TYPE_DIGEST'] = Digest::SHA2.hexdigest(Optcarrot::VERSION)
ENV['REPO_NAME'] = 'ruby'
ENV['ORGANIZATION_NAME'] ... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | liquid_benchmarks/benchmark_liquid.rb | Ruby | mit | 49 | master | 387 | require 'benchmark/ips'
require 'json'
require_relative '../support/benchmark_runner'
module Benchmark
module Liquid
def liquid(label=nil, version: ::Liquid::VERSION.to_s, time: 10, disable_gc: false, warmup: 5, &block)
Benchmark::Runner.run(label, version: version, time: time, disable_gc: disable_gc, war... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | liquid_benchmarks/driver.rb | Ruby | mit | 49 | master | 3,526 | #
# Liquid Benchmark driver
#
require 'digest'
require 'net/http'
require 'json'
require 'pathname'
require 'optparse'
RAW_URL = 'https://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/liquid/benchmarks/'
class BenchmarkDriver
def self.benchmark(options)
self.new(options).run
end
def initiali... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | discourse/benchmarks/bench.rb | Ruby | mit | 49 | master | 12,002 | require "socket"
require "csv"
require "yaml"
require "optparse"
require "fileutils"
require 'net/http'
require 'digest'
@include_env = false
@result_file = nil
@iterations = 500
@best_of = 1
@mem_stats = false
@unicorn = false
@dump_heap = false
@concurrency = 1
@skip_asset_bundle = false
@unicorn_workers = 3
opts =... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | discourse/benchmarks/patches/active_support_duration.rb | Ruby | mit | 49 | master | 358 | # https://github.com/rails/rails/issues/21296
# https://bugs.ruby-lang.org/issues/11465
# This has been fixed in Rails 4.2 but we run Ruby trunk benchmarks against Discourse
# on Rails 4.1
module ActiveSupport
refine Duration do
def respond_to_missing?(method, include_private=false)
@value.respond_to?(metho... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | discourse/rails_ruby_bench/bench.rb | Ruby | mit | 49 | master | 4,678 | require 'socket'
require 'optparse'
require 'fileutils'
require 'net/http'
require 'digest'
require 'yaml'
require 'json'
@result_file = "benchmark_out.json"
@iterations = 3000
@rrb_dir = "../.."
opts = OptionParser.new do |o|
o.banner = "Usage: ruby bench.rb [options]"
o.on("-o", "--output [FILE]", "Output resu... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/benchmark_runner.rb | Ruby | mit | 49 | master | 1,637 | require 'benchmark/ips'
require 'json'
module Benchmark
module Runner
def self.run(label=nil, version:, time:, disable_gc:, warmup:, &block)
unless block_given?
raise ArgumentError.new, "You must pass block to run"
end
GC.disable if disable_gc
ips_result = compute_ips(time, warm... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/helpers.rb | Ruby | mit | 49 | master | 239 | STRING_COLUMNS_COUNT = 25
def db_adapter
ENV['DATABASE_URL'].split(":")[0]
end
def db_setup(script:)
Dir.chdir("../../support/setup") do
`DATABASE_URL=#{ENV.fetch("DATABASE_URL")} BUNDLE_GEMFILE=Gemfile ruby #{script}`
end
end |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/setup/bm_preload_setup.rb | Ruby | mit | 49 | master | 789 | require "bundler/setup"
require "active_record"
ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :name, :email
t.integer :topic_id
t.timestamps null: false
end
c... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/setup/bm_validations_valid_setup.rb | Ruby | mit | 49 | master | 600 | require "bundler/setup"
require "active_record"
ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.string :title
t.string :author
t.text :body
t.integer :sequence
t.in... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/setup/bm_with_default_scope_setup.rb | Ruby | mit | 49 | master | 697 | require "bundler/setup"
require "active_record"
ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :name
t.string :email
t.boolean :approved
t.integer :age
t.da... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/setup/bm_scope_all_setup.rb | Ruby | mit | 49 | master | 632 | require "bundler/setup"
require "active_record"
ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :name
t.string :email
t.boolean :approved
t.integer :age
t.d... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/setup/bm_scope_where_setup.rb | Ruby | mit | 49 | master | 676 | require "bundler/setup"
require "active_record"
ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :name
t.string :email
t.boolean :approved
t.integer :age
t.da... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/setup/bm_discourse_setup.rb | Ruby | mit | 49 | master | 4,184 | require "bundler/setup"
require "active_record"
ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :topics, force: true do |t|
t.timestamps null: false
t.string "title"
t.datetime "bumped_at"
t.strin... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/setup/bm_finders_setup.rb | Ruby | mit | 49 | master | 734 | require "bundler/setup"
require "active_record"
ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :name
t.string :email
t.boolean :approved
t.integer :age
t.da... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/setup/bm_destroy_setup.rb | Ruby | mit | 49 | master | 296 | require "bundler/setup"
require "active_record"
ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :name, :email
t.timestamps null: false
end
end |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/setup/bm_create_string_columns_setup.rb | Ruby | mit | 49 | master | 375 | require "bundler/setup"
require "active_record"
require_relative "../helpers"
ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
STRING_COLUMNS_COUNT.times do |i|
t.string :"colum... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | support/setup/bm_validations_invalid_setup.rb | Ruby | mit | 49 | master | 410 | require "bundler/setup"
require "active_record"
ActiveRecord::Base.establish_connection(ENV.fetch('DATABASE_URL'))
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.string :title
t.string :author
t.text :body
t.integer :sequence
t.in... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | pg/Gemfile | Ruby | mit | 49 | master | 235 | source "https://rubygems.org"
module ::Kernel
def pg_master?
ENV["PG_MASTER"] == '1'
end
end
if pg_master?
gem 'pg', github: 'ged/ruby-pg'
else
gem 'pg', path: '/ruby-pg'
end
gem 'benchmark-ips', '~> 2.2.0'
gem 'byebug' |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | pg/benchmarks/bm_scope_all.rb | Ruby | mit | 49 | master | 639 | require 'bundler/setup'
require 'pg'
require_relative 'support/benchmark_pg'
db_setup script: "bm_scope_all_setup.rb"
connection = PG.connect(ENV.fetch("DATABASE_URL"))
type_mapper = PG::BasicTypeMapForResults.new(connection)
Benchmark.pg("pg/scope_all", time: 5) do
str = ""
result = connection.exec("SELECT nam... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | pg/benchmarks/bm_scope_all_over_select.rb | Ruby | mit | 49 | master | 616 | require 'bundler/setup'
require 'pg'
require_relative 'support/benchmark_pg'
db_setup script: "bm_scope_all_setup.rb"
connection = PG.connect(ENV.fetch("DATABASE_URL"))
type_mapper = PG::BasicTypeMapForResults.new(connection)
Benchmark.pg("pg/scope_all_over_select", time: 5) do
str = ""
result = connection.exec... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | pg/benchmarks/driver.rb | Ruby | mit | 49 | master | 373 | require 'bundler/setup'
require 'optparse'
require_relative 'pg_suite_runner'
options = {
pattern: []
}
OptionParser.new do |opts|
opts.banner = 'Usage: ruby driver.rb [options]'
opts.on('-p', '--pattern <PATTERN1,PATTERN2,PATTERN3>', 'Benchmark name pattern') do |value|
options[:pattern] = value.split(','... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | pg/benchmarks/bm_discourse.rb | Ruby | mit | 49 | master | 1,983 | require 'bundler/setup'
require 'pg'
require 'byebug'
require 'time'
require_relative 'support/benchmark_pg'
db_setup script: "bm_discourse_setup.rb"
conn = PG.connect(ENV.fetch("DATABASE_URL"))
user = conn.exec("SELECT * FROM users ORDER BY users.id LIMIT 1").first
Benchmark.pg("pg/discourse", time: 5) do
str = ... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | pg/benchmarks/pg_suite_runner.rb | Ruby | mit | 49 | master | 2,789 | # PG suite runner
require 'net/http'
require 'json'
require 'pathname'
require 'pg'
require 'digest'
class PGSuiteRunner
RAW_URL = 'https://raw.githubusercontent.com/ruby-bench/ruby-bench-suite/master/pg/benchmarks/'
DATABASE_URL = "postgres://postgres@postgres:5432/rubybench"
def self.run(options)
new(op... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | pg/benchmarks/support/benchmark_pg.rb | Ruby | mit | 49 | master | 393 | require 'pg'
require_relative '../../../support/benchmark_runner'
require_relative '../../../support/helpers'
module Benchmark
module PG
def pg(label = nil, version: ::PG::VERSION.to_s, time:, disable_gc: true, warmup: 3, &block)
Benchmark::Runner.run(label, version: version, time: time, disable_gc: disab... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/driver.rb | Ruby | mit | 49 | master | 2,080 | #!/usr/bin/env ruby
require 'digest'
require 'optparse'
require 'shellwords'
opt = { pattern: [], runner: 'seconds' }
OptionParser.new{|o|
o.on('-r', '--runner RUNNER', String, "Runner (default: seconds)"){|r|
opt[:runner] = r
}
o.on('-e', '--executables [EXEC]', "Specify benchmark target (e1::path1)"){|e|... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm_thread_queue.rb | Ruby | mit | 49 | master | 200 | require 'thread'
n = 1_000_000
q = Thread::Queue.new
consumer = Thread.new{
while q.pop
# consuming
end
}
producer = Thread.new{
n.times{
q.push true
}
q.push nil
}
consumer.join |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm_thread_pass.rb | Ruby | mit | 49 | master | 220 | # Plenty Thtread.pass
# A performance may depend on GVL implementation.
tmax = (ARGV.shift || 2).to_i
lmax = 200_000 / tmax
(1..tmax).map{
Thread.new{
lmax.times{
Thread.pass
}
}
}.each{|t| t.join} |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/app_mandelbrot.rb | Ruby | mit | 49 | master | 280 | require 'complex'
def mandelbrot? z
i = 0
while i<100
i += 1
z = z * z
return false if z.abs > 2
end
true
end
ary = []
(0..1000).each{|dx|
(0..1000).each{|dy|
x = dx / 50.0
y = dy / 50.0
c = Complex(x, y)
ary << c if mandelbrot?(c)
}
} |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_exception.rb | Ruby | mit | 49 | master | 874 | #!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: except-ruby.code,v 1.4 2004/11/13 07:41:33 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
$HI = 0
$LO = 0
NUM = 250000 # Integer(ARGV[0] || 1)
class Lo_Exception < Exception
def initialize(num)
@value = num
end
end
class Hi_Exception < Exception
def init... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm_thread_sized_queue4.rb | Ruby | mit | 49 | master | 387 | require 'thread'
# many producers, many consumers
nr = 1_000_000
n = 10
m = 10
q = Thread::SizedQueue.new(100)
consumers = n.times.map do
Thread.new do
while q.pop
# consuming
end
end
end
producers = m.times.map do
Thread.new do
while nr > 0
q.push true
nr -= 1
end
end
end
pr... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_ackermann.rb | Ruby | mit | 49 | master | 315 | #!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: ackermann-ruby.code,v 1.4 2004/11/13 07:40:41 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
def ack(m, n)
if m == 0 then
n + 1
elsif n == 0 then
ack(m - 1, 1)
else
ack(m - 1, ack(m, n - 1))
end
end
NUM = 9
ack(3, NUM) |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/array_small_diff.rb | Ruby | mit | 49 | master | 442 | MIN_SIZE = ENV.fetch('SMALL_ARRAY_MIN', 0).to_i
MAX_SIZE = ENV.fetch('SMALL_ARRAY_MAX', 16).to_i
ITERATIONS = ENV.fetch('SMALL_ARRAY_ITERATIONS', 100).to_i
ARRAYS = (MIN_SIZE..MAX_SIZE).map do |size1|
(MIN_SIZE..MAX_SIZE).map do |size2|
[Array.new(size1) { rand(MAX_SIZE) }, Array.new(size2) { rand(MAX_SIZE) }]
... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm_thread_condvar2.rb | Ruby | mit | 49 | master | 713 | # many threads, one mutex, many condvars
require 'thread'
m = Mutex.new
cv1 = ConditionVariable.new
cv2 = ConditionVariable.new
max = 1000
n = 100
waiting = 0
scvs = []
waiters = n.times.map do |i|
start_cv = ConditionVariable.new
scvs << start_cv
start_mtx = Mutex.new
start_mtx.synchronize do
th = Thread.n... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/io_copy_stream_write.rb | Ruby | mit | 49 | master | 570 | # The goal of this is to use a synthetic (non-IO) reader
# to trigger the read/write loop of IO.copy_stream,
# bypassing in-kernel mechanisms like sendfile for zero copy,
# so we wrap the /dev/zero IO object:
class Zero
def initialize
@n = 100000
@in = File.open('/dev/zero', 'rb')
end
def read(len, buf)... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/io_pipe_rw.rb | Ruby | mit | 49 | master | 279 | # Measure uncontended GVL performance via read/write with 1:1 threading
# If we switch to M:N threading, this will benchmark something else...
r, w = IO.pipe
src = '0'.freeze
dst = String.new
i = 0
while i < 1_000_000
i += 1
w.write(src)
r.read(1, dst)
end
w.close
r.close |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/hash_long.rb | Ruby | mit | 49 | master | 297 | k1 = "Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong";
k2 = "Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping Pong Ping";
h = {k1 => 0, k2 => 0};
3000000.times{|i| k = i % 2 ? k2 : k1; h [k] = h[k] + 1} |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_binary_trees.rb | Ruby | mit | 49 | master | 1,312 | # The Computer Language Shootout Benchmarks
# http://shootout.alioth.debian.org
#
# contributed by Jesse Millikan
# disable output
alias puts_orig puts
def puts str
# disable puts
end
def item_check(tree)
if tree[0] == nil
tree[1]
else
tree[1] + item_check(tree[0]) - item_check(tree[2])
end
end
def bottom_u... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_sieve.rb | Ruby | mit | 49 | master | 399 | # from http://www.bagley.org/~doug/shootout/bench/sieve/sieve.ruby
num = 500
count = i = j = 0
flags0 = Array.new(8192,1)
k = 0
while k < num
k += 1
count = 0
flags = flags0.dup
i = 2
while i<8192
i += 1
if flags[i]
# remove all multiples of prime: i
j = i*i
while j < 8192
j ... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/array_shift.rb | Ruby | mit | 49 | master | 298 | require 'benchmark'
Benchmark.bm do |x|
[10_000,1_000_000,100_000_000].each do |n|
ary = Array.new(n,0)
GC.start
x.report("#{n}:shift"){ ary.shift }
(0..4).each do |i|
ary = Array.new(n,0)
GC.start
x.report("#{n}:shift(#{i})"){ ary.shift(i) }
end
end
end |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm_thread_condvar1.rb | Ruby | mit | 49 | master | 476 | # two threads, two mutex, two condvar ping-pong
require 'thread'
m1 = Mutex.new
m2 = Mutex.new
cv1 = ConditionVariable.new
cv2 = ConditionVariable.new
max = 100000
i = 0
wait = nil
m2.synchronize do
wait = Thread.new do
m1.synchronize do
m2.synchronize { cv2.signal }
while (i += 1) < max
cv1.w... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm_thread_sized_queue2.rb | Ruby | mit | 49 | master | 336 | require 'thread'
# one producer, many consumers
n = 1_000_000
m = 10
q = Thread::SizedQueue.new(100)
consumers = m.times.map do
Thread.new do
while q.pop
# consuming
end
end
end
producer = Thread.new do
while n > 0
q.push true
n -= 1
end
m.times { q.push nil }
end
producer.join
consume... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/hash_aref_dsym_long.rb | Ruby | mit | 49 | master | 474 | # [ruby-core:70129] [Bug #11396]
collection_size = 200000
sample_size = 10000
values = (1..collection_size).to_a.map do |x|
"THIS IS A LONGER STRING THAT IS ALSO UNIQUE #{x}"
end
symbol_hash = {}
values.each do |x|
symbol_hash[x.to_sym] = 1
end
# use the same samples each time to minimize deviations
rng = Rando... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_array.rb | Ruby | mit | 49 | master | 409 | #!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: ary-ruby.code,v 1.4 2004/11/13 07:41:27 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
# with help from Paul Brannan and Mark Hubbart
n = 9000 # Integer(ARGV.shift || 1)
x = Array.new(n)
y = Array.new(n, 0)
n.times{|bi|
x[bi] = bi + 1
}
(0 .. 999).each do |e|
... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_nbody.rb | Ruby | mit | 49 | master | 3,011 | # The Computer Language Shootout
# http://shootout.alioth.debian.org
#
# Optimized for Ruby by Jesse Millikan
# From version ported by Michael Neumann from the C gcc version,
# which was written by Christoph Bauer.
SOLAR_MASS = 4 * Math::PI**2
DAYS_PER_YEAR = 365.24
def _puts *args
end
class Planet
attr_accessor :x... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/file_rename.rb | Ruby | mit | 49 | master | 271 | # rename file
require 'tempfile'
max = 100_000
tmp = [ Tempfile.new('rename-a'), Tempfile.new('rename-b') ]
a, b = tmp.map { |x| x.path }
tmp.each { |t| t.close } # Windows can't rename files without closing them
max.times do
File.rename(a, b)
File.rename(b, a)
end |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/io_nonblock_noex2.rb | Ruby | mit | 49 | master | 337 | nr = 1_000_000
i = 0
msg = '.'
buf = '.'
begin
r, w = IO.pipe
while i < nr
i += 1
w.write_nonblock(msg, exception: false)
r.read_nonblock(1, buf, exception: false)
end
rescue ArgumentError # old Rubies
while i < nr
i += 1
w.write_nonblock(msg)
r.read_nonblock(1, buf)
end
ensure
r.clo... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm_thread_sized_queue3.rb | Ruby | mit | 49 | master | 323 | require 'thread'
# many producers, one consumer
n = 1_000_000
m = 10
q = Thread::SizedQueue.new(100)
consumer = Thread.new do
while q.pop
# consuming
end
end
producers = m.times.map do
Thread.new do
while n > 0
q.push true
n -= 1
end
end
end
producers.each(&:join)
q.push nil
consumer.jo... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/io_nonblock_noex.rb | Ruby | mit | 49 | master | 345 | nr = 1_000_000
i = 0
msg = '.'
buf = '.'
noex = { exception: false }
begin
r, w = IO.pipe
while i < nr
i += 1
w.write_nonblock(msg, **noex)
r.read_nonblock(1, buf, **noex)
end
rescue ArgumentError # old Rubies
while i < nr
i += 1
w.write_nonblock(msg)
r.read_nonblock(1, buf)
end
ensure... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_concatenate.rb | Ruby | mit | 49 | master | 337 | #!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: strcat-ruby.code,v 1.4 2004/11/13 07:43:28 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
# based on code from Aristarkh A Zagorodnikov and Dat Nguyen
STUFF = "hello\n"
i = 0
while i<10
i += 1
hello = ''
4_000_000.times do |e|
hello << STUFF
end
end
# put... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_fannkuch.rb | Ruby | mit | 49 | master | 928 | # The Computer Language Shootout
# http://shootout.alioth.debian.org/
# Contributed by Sokolov Yura
# Modified by Ryan Williams
def fannkuch(n)
maxFlips, m, r, check = 0, n-1, n, 0
count = (1..n).to_a
perm = (1..n).to_a
while true
if check < 30
puts "#{perm}"
check += 1
end
... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/io_copy_stream_write_socket.rb | Ruby | mit | 49 | master | 809 | # The goal of this is to use a synthetic (non-IO) reader
# to trigger the read/write loop of IO.copy_stream,
# bypassing in-kernel mechanisms like sendfile for zero copy,
# so we wrap the /dev/zero IO object:
class Zero
def initialize
@n = 100000
@in = File.open('/dev/zero', 'rb')
end
def read(len, buf)
... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/app_lc_fizzbuzz.rb | Ruby | mit | 49 | master | 15,832 | #
# FizzBuzz program using only lambda calculus
#
# This program is quoted from
# "Understanding Computation" by Tom Stuart
# http://computationbook.com/
#
# You can understand why this program works fine by reading this book.
#
solution = -> k { -> f { -> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm_thread_mutex2.rb | Ruby | mit | 49 | master | 278 | # two threads, one mutex
require 'thread'
m = Thread::Mutex.new
r = 0
max = 2000
lmax = (max * max)/2
(1..2).map{
Thread.new{
i = 0
while i<lmax
i += 1
m.synchronize{
r += 1
}
end
}
}.each{|e|
e.join
}
raise r.to_s if r != max * max |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm_thread_mutex3.rb | Ruby | mit | 49 | master | 259 | # 1000 threads, one mutex
require 'thread'
m = Thread::Mutex.new
r = 0
max = 2000
(1..max).map{
Thread.new{
i = 0
while i<max
i += 1
m.synchronize{
r += 1
}
end
}
}.each{|e|
e.join
}
raise r.to_s if r != max * max |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_object.rb | Ruby | mit | 49 | master | 992 | #!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: objinst-ruby.code,v 1.4 2004/11/13 07:42:25 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
# with help from Aristarkh Zagorodnikov
class Toggle
def initialize(start_state)
@bool = start_state
end
def value
@bool
end
def activate
... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_mandelbrot.rb | Ruby | mit | 49 | master | 1,384 | # The Computer Language Benchmarks Game
# http://shootout.alioth.debian.org/
#
# contributed by Karl von Laudermann
# modified by Jeremy Echols
size = 600 # ARGV[0].to_i
puts "P4\n#{size} #{size}"
ITER = 49 # Iterations - 1 for easy for..in looping
LIMIT_SQUARED = 4.0 # ... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_nsieve.rb | Ruby | mit | 49 | master | 679 | # The Computer Language Shootout
# http://shootout.alioth.debian.org/
#
# contributed by Glenn Parker, March 2005
# modified by Evan Phoenix, Sept 2006
def sieve(m)
flags = Flags.dup[0,m]
count = 0
pmax = m - 1
p = 2
while p <= pmax
unless flags[p].zero?
count += 1
mult = p
while mult <... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm_thread_mutex1.rb | Ruby | mit | 49 | master | 289 | # one thread, one mutex (no contention)
require 'thread'
m = Thread::Mutex.new
r = 0
max = 2000
lmax = max * max
(1..1).map{
Thread.new{
i = 0
while i<lmax
i += 1
m.synchronize{
r += 1
}
end
}
}.each{|e|
e.join
}
raise r.to_s if r != max * max |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_partial_sums.rb | Ruby | mit | 49 | master | 774 | n = 2_500_000 # (ARGV.shift || 1).to_i
alt = 1.0 ; s0 = s1 = s2 = s3 = s4 = s5 = s6 = s7 = s8 = 0.0
1.upto(n) do |d|
d = d.to_f ; d2 = d * d ; d3 = d2 * d ; ds = Math.sin(d) ; dc = Math.cos(d)
s0 += (2.0 / 3.0) ** (d - 1.0)
s1 += 1.0 / Math.sqrt(d)
s2 += 1.0 / (d * (d + 1.0))
s3 += 1.0 / (d3 * ds * ds)
s... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/array_small_or.rb | Ruby | mit | 49 | master | 442 | MIN_SIZE = ENV.fetch('SMALL_ARRAY_MIN', 0).to_i
MAX_SIZE = ENV.fetch('SMALL_ARRAY_MAX', 16).to_i
ITERATIONS = ENV.fetch('SMALL_ARRAY_ITERATIONS', 100).to_i
ARRAYS = (MIN_SIZE..MAX_SIZE).map do |size1|
(MIN_SIZE..MAX_SIZE).map do |size2|
[Array.new(size1) { rand(MAX_SIZE) }, Array.new(size2) { rand(MAX_SIZE) }]
... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_nested_loop.rb | Ruby | mit | 49 | master | 457 | #!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: nestedloop-ruby.code,v 1.4 2004/11/13 07:42:22 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
# from Avi Bryant
n = 16 # Integer(ARGV.shift || 1)
x = 0
n.times do
n.times do
n.times do
n.times do
n.times do
... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/fiber_chain.rb | Ruby | mit | 49 | master | 651 | # Check performance of fiber creation and transfer.
def make_link(previous)
Fiber.new do
while message = previous.resume
Fiber.yield(message)
end
end
end
def make_chain(length, &block)
chain = Fiber.new(&block)
(length - 1).times do
chain = make_link(chain)
end
return chain
end
def ru... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/app_pentomino.rb | Ruby | mit | 49 | master | 2,061 | #!/usr/local/bin/ruby
# This program is contributed by Shin Nishiyama
# modified by K.Sasada
NP = 5
ROW = 8 + NP
COL = 8
$p = []
$b = []
$no = 0
def piece(n, a, nb)
nb.each{|x|
a[n] = x
if n == NP-1
$p << [a.sort]
else
nbc=nb.dup
[-ROW, -1, 1, ROW].each{|d|
if x+d > 0 and no... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_fasta.rb | Ruby | mit | 49 | master | 1,888 | # The Computer Language Shootout
# http://shootout.alioth.debian.org/
# Contributed by Sokolov Yura
$last = 42.0
def gen_random(max, im=139968, ia=3877, ic=29573)
(max * ($last = ($last * ia + ic) % im)) / im
end
alu =
"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG"+
"GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm_thread_pipe.rb | Ruby | mit | 49 | master | 267 | # Measure small and plenty pipe read/write.
# A performance may depend on GVL implementation.
lmax = 100_000
r, w = IO.pipe
[Thread.new{
lmax.times{
w.write('a')
}
p "w:exit"
}, Thread.new{
lmax.times{
r.read(1)
}
p "r:exit"
}].each{|t| t.join} |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/hash_aref_sym_long.rb | Ruby | mit | 49 | master | 428 | h = {}
syms = %w[puts warn syswrite write stat bacon lettuce tomato
some symbols in this array may already be interned others should not be
hash browns make good breakfast but not cooked using prime numbers
shift for division entries delete_if keys exist?
]
begin
syms = eval("%i[#{syms.join(' ')}]")
rescue SyntaxErr... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_pidigits.rb | Ruby | mit | 49 | master | 1,594 | # The Great Computer Language Shootout
# http://shootout.alioth.debian.org/
#
# contributed by Gabriele Renzi
class PiDigitSpigot
def initialize()
@z = Transformation.new 1,0,0,1
@x = Transformation.new 0,0,0,0
@inverse = Transformation.new 0,0,0,0
end
def next!
@y = @z.ex... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/app_answer.rb | Ruby | mit | 49 | master | 310 | def ack(m, n)
if m == 0 then
n + 1
elsif n == 0 then
ack(m - 1, 1)
else
ack(m - 1, ack(m, n - 1))
end
end
def the_answer_to_life_the_universe_and_everything
(ack(3,7).to_s.split(//).inject(0){|s,x| s+x.to_i}.to_s + "2" ).to_i
end
answer = the_answer_to_life_the_universe_and_everything |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/so_matrix.rb | Ruby | mit | 49 | master | 1,010 | #!/usr/bin/ruby
# -*- mode: ruby -*-
# $Id: matrix-ruby.code,v 1.4 2004/11/13 07:42:14 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
n = 60 #Integer(ARGV.shift || 1)
size = 40
def mkmatrix(rows, cols)
count = 1
mx = Array.new(rows)
(0 .. (rows - 1)).each do |bi|
row = Array.new(cols, 0)
... |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/vm3_backtrace.rb | Ruby | mit | 49 | master | 252 | # get last backtrace
begin
caller(0, 0)
rescue ArgumentError
alias caller_orig caller
def caller lev, n
caller_orig(lev)[0..n]
end
end
def rec n
if n < 0
100_000.times{
caller(0, 1)
}
else
rec(n-1)
end
end
rec 50 |
github | ruby-bench/ruby-bench-suite | https://github.com/ruby-bench/ruby-bench-suite | ruby/benchmark/array_small_and.rb | Ruby | mit | 49 | master | 442 | MIN_SIZE = ENV.fetch('SMALL_ARRAY_MIN', 0).to_i
MAX_SIZE = ENV.fetch('SMALL_ARRAY_MAX', 16).to_i
ITERATIONS = ENV.fetch('SMALL_ARRAY_ITERATIONS', 100).to_i
ARRAYS = (MIN_SIZE..MAX_SIZE).map do |size1|
(MIN_SIZE..MAX_SIZE).map do |size2|
[Array.new(size1) { rand(MAX_SIZE) }, Array.new(size2) { rand(MAX_SIZE) }]
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.