repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/stack_prof.rb | lib/test_prof/stack_prof.rb | # frozen_string_literal: true
module TestProf
# StackProf wrapper.
#
# Has 2 modes: global and per-example.
#
# Example:
#
# # To activate global profiling you can use env variable
# TEST_STACK_PROF=1 rspec ...
#
# # or in your code
# TestProf::StackProf.run
#
# To profile a specific ... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/version.rb | lib/test_prof/version.rb | # frozen_string_literal: true
module TestProf
VERSION = "1.5.0"
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/any_fixture.rb | lib/test_prof/any_fixture.rb | # frozen_string_literal: true
require "test_prof/core"
require "test_prof/ext/float_duration"
require "test_prof/any_fixture/dump"
module TestProf
# Make DB fixtures from blocks.
module AnyFixture
INSERT_RXP = /^INSERT INTO (\S+)/.freeze
using FloatDuration
# AnyFixture configuration
class Confi... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/tag_prof.rb | lib/test_prof/tag_prof.rb | # frozen_string_literal: true
require "test_prof/tag_prof/result"
require "test_prof/tag_prof/printers/simple"
require "test_prof/tag_prof/printers/html"
module TestProf
module TagProf # :nodoc:
end
end
require "test_prof/tag_prof/rspec" if TestProf.rspec?
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_prof.rb | lib/test_prof/factory_prof.rb | # frozen_string_literal: true
require "test_prof/factory_prof/printers/simple"
require "test_prof/factory_prof/printers/flamegraph"
require "test_prof/factory_prof/printers/nate_heckler"
require "test_prof/factory_prof/printers/json"
require "test_prof/factory_prof/factory_builders/factory_bot"
require "test_prof/fact... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_doctor.rb | lib/test_prof/factory_doctor.rb | # frozen_string_literal: true
require "test_prof/factory_bot"
require "test_prof/factory_doctor/factory_bot_patch"
require "test_prof/factory_doctor/fabrication_patch"
module TestProf
# FactoryDoctor is a tool that helps you identify
# tests that perform unnecessary database queries.
module FactoryDoctor
cl... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/ruby_prof.rb | lib/test_prof/ruby_prof.rb | # frozen_string_literal: true
module TestProf
# RubyProf wrapper.
#
# Has 2 modes: global and per-example.
#
# Example:
#
# # To activate global profiling you can use env variable
# TEST_RUBY_PROF=1 rspec ...
#
# # or in your code
# TestProf::RubyProf.run
#
# To profile a specific exa... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/logging.rb | lib/test_prof/logging.rb | # frozen_string_literal: true
module TestProf
# Helper for output printing
module Logging
COLORS = {
INFO: "\e[34m", # blue
WARN: "\e[33m", # yellow
ERROR: "\e[31m" # red
}.freeze
class Formatter
def call(severity, _time, progname, msg)
colorize(severity.to_sym, "[#{pro... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_default.rb | lib/test_prof/factory_default.rb | # frozen_string_literal: true
require "test_prof/core"
require "test_prof/factory_default/factory_bot_patch"
require "test_prof/factory_default/fabrication_patch"
require "test_prof/ext/float_duration"
require "test_prof/ext/active_record_refind" if defined?(::ActiveRecord::Base)
module TestProf
# FactoryDefault ... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/utils.rb | lib/test_prof/utils.rb | # frozen_string_literal: true
module TestProf
module Utils # :nodoc:
class << self
# Verify that loaded gem has correct version
def verify_gem_version(gem_name, at_least: nil, at_most: nil)
raise ArgumentError, "Please, provide `at_least` or `at_most` argument" if
at_least.nil? && a... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/vernier.rb | lib/test_prof/vernier.rb | # frozen_string_literal: true
module TestProf
# Vernier wrapper.
#
# Has 2 modes: global and per-example.
#
# Example:
#
# # To activate global profiling you can use env variable
# TEST_VERNIER=1 rspec ...
#
# To profile a specific examples add :vernier tag to it:
#
# it "is doing heavy s... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/memory_prof.rb | lib/test_prof/memory_prof.rb | # frozen_string_literal: true
require "test_prof/memory_prof/tracker"
require "test_prof/memory_prof/printer"
module TestProf
# MemoryProf can help in detecting test examples causing memory spikes.
# It supports two metrics: RSS and allocations.
#
# Example:
#
# TEST_MEM_PROF='rss' rspec ...
# TEST_... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_all_stub.rb | lib/test_prof/factory_all_stub.rb | # frozen_string_literal: true
require "test_prof/core"
require "test_prof/factory_bot"
require "test_prof/factory_all_stub/factory_bot_patch"
module TestProf
# FactoryAllStub inject into FactoryBot to make
# all strategies be `build_stubbed` strategy.
module FactoryAllStub
LOCAL_NAME = :__factory_bot_stub_a... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_bot.rb | lib/test_prof/factory_bot.rb | # frozen_string_literal: true
module TestProf # :nodoc: all
TestProf.require("active_support")
TestProf.require("factory_bot") do
TestProf::FactoryBot = Object.const_get("::FactoryBot")
end
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/event_prof.rb | lib/test_prof/event_prof.rb | # frozen_string_literal: true
require "test_prof/rspec_stamp"
require "test_prof/event_prof/profiler"
require "test_prof/event_prof/instrumentations/active_support"
require "test_prof/event_prof/monitor"
require "test_prof/utils/sized_ordered_set"
module TestProf
# EventProf profiles your tests and suites against c... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/tps_prof.rb | lib/test_prof/tps_prof.rb | # frozen_string_literal: true
require "test_prof/tps_prof/profiler"
require "test_prof/tps_prof/reporter/text"
module TestProf
# TPSProf shows top-N example group based on their tests-per-second value.
#
# Example:
#
# TPS_PROF=10 rspec ...
#
module TPSProf
class Configuration
attr_accessor ... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/rspec_dissect.rb | lib/test_prof/rspec_dissect.rb | # frozen_string_literal: true
require "test_prof/rspec_stamp"
require "test_prof/logging"
module TestProf
# RSpecDissect tracks how much time do you spend in `before` hooks
# and memoization helpers (i.e. `let`) in your tests.
module RSpecDissect
module ExampleInstrumentation # :nodoc:
def run_before_... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/before_all.rb | lib/test_prof/before_all.rb | # frozen_string_literal: true
require "test_prof/core"
module TestProf
# `before_all` helper configuration
module BeforeAll
class AdapterMissing < StandardError # :nodoc:
MSG = "Please, provide an adapter for `before_all` " \
"through `TestProf::BeforeAll.adapter = MyAdapter`"
def ini... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/rspec_stamp.rb | lib/test_prof/rspec_stamp.rb | # frozen_string_literal: true
require "test_prof/logging"
require "test_prof/rspec_stamp/parser"
module TestProf
# Mark RSpec examples with provided tags
module RSpecStamp
EXAMPLE_RXP = /(\s*)(\w+\s*(?:.*)\s*)(do|{)/.freeze
# RSpecStamp configuration
class Configuration
attr_reader :tags
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_doctor/fabrication_patch.rb | lib/test_prof/factory_doctor/fabrication_patch.rb | # frozen_string_literal: true
module TestProf
module FactoryDoctor
# Wrap #run method with FactoryDoctor tracking
module FabricationPatch
def create(*)
FactoryDoctor.within_factory(:create) { super }
end
end
end
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_doctor/minitest.rb | lib/test_prof/factory_doctor/minitest.rb | # frozen_string_literal: true
require "minitest/base_reporter"
require "test_prof/ext/float_duration"
module Minitest
module TestProf # :nodoc:
# Add fd_ignore methods
module FactoryDoctorIgnore
def fd_ignore
::TestProf::FactoryDoctor.ignore!
end
end
Minitest::Test.include Facto... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_doctor/rspec.rb | lib/test_prof/factory_doctor/rspec.rb | # frozen_string_literal: true
require "test_prof/ext/float_duration"
module TestProf
module FactoryDoctor
class RSpecListener # :nodoc:
include Logging
using FloatDuration
SUCCESS_MESSAGE = 'FactoryDoctor says: "Looks good to me!"'
NOTIFICATIONS = %i[
example_started
e... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_doctor/factory_bot_patch.rb | lib/test_prof/factory_doctor/factory_bot_patch.rb | # frozen_string_literal: true
require "test_prof/ext/factory_bot_strategy"
module TestProf
module FactoryDoctor
# Wrap #run method with FactoryDoctor tracking
module FactoryBotPatch
using TestProf::FactoryBotStrategy
def run(strategy = @strategy)
FactoryDoctor.within_factory(strategy.cr... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/memory_prof/tracker.rb | lib/test_prof/memory_prof/tracker.rb | # frozen_string_literal: true
require "test_prof/memory_prof/tracker/linked_list"
require "test_prof/memory_prof/tracker/rss_tool"
module TestProf
module MemoryProf
# Tracker is responsible for tracking memory usage and determining
# the top n examples and groups. There are two types of trackers:
# Allo... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/memory_prof/minitest.rb | lib/test_prof/memory_prof/minitest.rb | # frozen_string_literal: true
require "minitest/base_reporter"
module Minitest
module TestProf
class MemoryProfReporter < BaseReporter # :nodoc:
attr_reader :tracker, :printer, :current_example
def initialize(io = $stdout, options = {})
super
configure_profiler(options)
@t... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/memory_prof/rspec.rb | lib/test_prof/memory_prof/rspec.rb | # frozen_string_literal: true
module TestProf
module MemoryProf
class RSpecListener
NOTIFICATIONS = %i[
example_started
example_finished
example_group_started
example_group_finished
].freeze
attr_reader :tracker, :printer
def initialize
@tracker =... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/memory_prof/printer.rb | lib/test_prof/memory_prof/printer.rb | # frozen_string_literal: true
require "test_prof/memory_prof/printer/number_to_human"
require "test_prof/ext/string_truncate"
module TestProf
module MemoryProf
class Printer
include Logging
using StringTruncate
def initialize(tracker)
@tracker = tracker
end
def print
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/memory_prof/tracker/linked_list.rb | lib/test_prof/memory_prof/tracker/linked_list.rb | # frozen_string_literal: true
module TestProf
module MemoryProf
class Tracker
# LinkedList is a linked list that track memory usage for individual examples/groups.
# A list node (`LinkedListNode`) represents an example/group and its memory usage info:
#
# * memory_at_start - the amount of... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/memory_prof/tracker/rss_tool.rb | lib/test_prof/memory_prof/tracker/rss_tool.rb | # frozen_string_literal: true
require "rbconfig"
module TestProf
module MemoryProf
class Tracker
module RssTool
class ProcFS
def initialize
@statm = File.open("/proc/#{$$}/statm", "r")
@page_size = get_page_size
end
def track
@stat... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/memory_prof/printer/number_to_human.rb | lib/test_prof/memory_prof/printer/number_to_human.rb | # frozen_string_literal: true
module TestProf
module MemoryProf
class Printer
module NumberToHuman
BASE = 1024
UNITS = %w[B KB MB GB TB PB EB ZB]
class << self
def convert(number)
exponent = exponent(number)
human_size = number.to_f / (BASE**expone... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/recipes/logging.rb | lib/test_prof/recipes/logging.rb | # frozen_string_literal: true
require "test_prof/core"
module TestProf
module Rails
# Add `with_logging` and `with_ar_logging helpers`
module LoggingHelpers
class << self
def logger=(logger)
@logger = logger
# swap global loggers
global_loggables.each do |loggabl... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/recipes/minitest/sample.rb | lib/test_prof/recipes/minitest/sample.rb | # frozen_string_literal: true
module TestProf
# Add ability to run only a specified number of example groups (randomly selected)
module MinitestSample
# Do not add these classes to resulted sample
CORE_RUNNABLES = [
Minitest::Test,
defined?(Minitest::Unit::TestCase) ? Minitest::Unit::TestCase :... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/recipes/minitest/before_all.rb | lib/test_prof/recipes/minitest/before_all.rb | # frozen_string_literal: true
require "test_prof/before_all"
Minitest.singleton_class.prepend(Module.new do
attr_reader :previous_klass
@previous_klass = nil
def run_one_method(klass, method_name)
return super unless klass.respond_to?(:parallelized) && klass.parallelized
if @previous_klass && @previou... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/recipes/rspec/let_it_be.rb | lib/test_prof/recipes/rspec/let_it_be.rb | # frozen_string_literal: true
require "test_prof/core"
require "test_prof/recipes/rspec/before_all"
module TestProf
# Just like `let`, but persist the result for the whole group.
# NOTE: Experimental and magical, for more control use `before_all`.
module LetItBe
class DuplicationError < StandardError; end
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/recipes/rspec/any_fixture.rb | lib/test_prof/recipes/rspec/any_fixture.rb | # frozen_string_literal: true
require "test_prof/any_fixture"
require "test_prof/any_fixture/dsl"
require "test_prof/ext/active_record_refind"
require "test_prof/recipes/rspec/before_all"
RSpec.shared_context "any_fixture:clean" do
extend TestProf::BeforeAll::RSpec
before_all do
TestProf::AnyFixture.clean
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/recipes/rspec/factory_default.rb | lib/test_prof/recipes/rspec/factory_default.rb | # frozen_string_literal: true
require "test_prof/factory_default"
TestProf::FactoryDefault.init
if defined?(TestProf::BeforeAll)
TestProf::BeforeAll.configure do |config|
config.before(:begin) do |context|
TestProf::FactoryDefault.current_context = context
end
config.after(:rollback) do |context... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/recipes/rspec/sample.rb | lib/test_prof/recipes/rspec/sample.rb | # frozen_string_literal: true
module TestProf
# Instance variable writer for RSpec::Core::World
module RSpecWorldSamplePatch
def filtered_examples=(val)
@filtered_examples = val
end
end
end
if ENV["SAMPLE"]
RSpec::Core::World.include(TestProf::RSpecWorldSamplePatch)
RSpec.configure do |config... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/recipes/rspec/factory_all_stub.rb | lib/test_prof/recipes/rspec/factory_all_stub.rb | # frozen_string_literal: true
require "test_prof/factory_all_stub"
TestProf::FactoryAllStub.init
RSpec.shared_context "factory:stub" do
prepend_before(:all) { TestProf::FactoryAllStub.enable! }
append_after(:all) { TestProf::FactoryAllStub.disable! }
end
RSpec.configure do |config|
config.include_context "fac... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/recipes/rspec/before_all.rb | lib/test_prof/recipes/rspec/before_all.rb | # frozen_string_literal: true
require "test_prof/before_all"
module TestProf
module BeforeAll
# Helper to wrap the whole example group into a transaction
module RSpec
def before_all(setup_fixtures: BeforeAll.config.setup_fixtures, &block)
raise ArgumentError, "Block is required!" unless block
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/vernier/rspec.rb | lib/test_prof/vernier/rspec.rb | # frozen_string_literal: true
require "test_prof/utils/rspec"
module TestProf
module Vernier
# Reporter for RSpec to profile specific examples with Vernier
class Listener # :nodoc:
class << self
attr_accessor :report_name_generator
end
self.report_name_generator = Utils::RSpec.met... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/utils/html_builder.rb | lib/test_prof/utils/html_builder.rb | # frozen_string_literal: true
require "json"
module TestProf
module Utils
# Generates static HTML reports with injected data
module HTMLBuilder
class << self
def generate(data:, template:, output:)
template = File.read(TestProf.asset_path(template))
template.sub! "/**REPORT... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/utils/rspec.rb | lib/test_prof/utils/rspec.rb | # frozen_string_literal: true
unless "".respond_to?(:parameterize)
require "test_prof/ext/string_parameterize"
using TestProf::StringParameterize
end
module TestProf
module Utils
module RSpec
class << self
def example_to_filename(example)
::RSpec::Core::Metadata.id_from(example.metad... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/utils/sized_ordered_set.rb | lib/test_prof/utils/sized_ordered_set.rb | # frozen_string_literal: true
module TestProf
module Utils
# Ordered set with capacity
class SizedOrderedSet
unless [].respond_to?(:bsearch_index)
require "test_prof/ext/array_bsearch_index"
using ArrayBSearchIndex
end
include Enumerable
def initialize(max_size, sort... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/before_all/isolator.rb | lib/test_prof/before_all/isolator.rb | # frozen_string_literal: true
TestProf::BeforeAll.configure do |config|
config.before(:begin) do
::Isolator.incr_thresholds!
end
config.after(:rollback) do
::Isolator.decr_thresholds!
end
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/before_all/adapters/active_record.rb | lib/test_prof/before_all/adapters/active_record.rb | # frozen_string_literal: true
module TestProf
module BeforeAll
module Adapters
# ActiveRecord adapter for `before_all`
module ActiveRecord
POOL_ARGS = ((::ActiveRecord::VERSION::MAJOR > 6) ? [:writing] : []).freeze
class << self
if ::ActiveRecord::Base.connection.pool.respo... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/tps_prof/profiler.rb | lib/test_prof/tps_prof/profiler.rb | # frozen_string_literal: true
require "test_prof/utils/sized_ordered_set"
module TestProf
module TPSProf
class Profiler
attr_reader :top_count, :groups, :total_count, :total_time, :threshold
def initialize(top_count, threshold: 10)
@threshold = threshold
@top_count = top_count
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/tps_prof/rspec.rb | lib/test_prof/tps_prof/rspec.rb | # frozen_string_literal: true
module TestProf
module TPSProf
class RSpecListener # :nodoc:
include Logging
NOTIFICATIONS = %i[
example_group_started
example_group_finished
example_started
example_finished
].freeze
attr_reader :reporter, :profiler
d... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/tps_prof/reporter/text.rb | lib/test_prof/tps_prof/reporter/text.rb | # frozen_string_literal: true
require "test_prof/ext/float_duration"
require "test_prof/ext/string_truncate"
module TestProf
module TPSProf
module Reporter
class Text
include Logging
using FloatDuration
using StringTruncate
def print(profiler)
groups = profiler.... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/tag_prof/result.rb | lib/test_prof/tag_prof/result.rb | # frozen_string_literal: true
module TestProf
module TagProf # :nodoc:
# Object holding all the stats for tags
class Result
attr_reader :tag, :data, :events
def initialize(tag, events = [])
@tag = tag
@events = events
@data = Hash.new do |h, k|
h[k] = {value: k... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/tag_prof/minitest.rb | lib/test_prof/tag_prof/minitest.rb | # frozen_string_literal: true
module Minitest
module TestProf
class TagProfReporter < BaseReporter # :nodoc:
attr_reader :results
def initialize(io = $stdout, _options = {})
super
@results = ::TestProf::TagProf::Result.new("type")
if event_prof_activated?
require "... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/tag_prof/rspec.rb | lib/test_prof/tag_prof/rspec.rb | # frozen_string_literal: true
module TestProf
module TagProf
class RSpecListener # :nodoc:
include Logging
NOTIFICATIONS = %i[
example_started
example_finished
].freeze
attr_reader :result, :printer
def initialize
@printer = (ENV["TAG_PROF_FORMAT"] == "htm... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/tag_prof/printers/simple.rb | lib/test_prof/tag_prof/printers/simple.rb | # frozen_string_literal: true
require "test_prof/ext/float_duration"
module TestProf::TagProf
module Printers
module Simple # :nodoc: all
class << self
include TestProf::Logging
using TestProf::FloatDuration
def dump(result)
msgs = []
msgs <<
<<~M... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/tag_prof/printers/html.rb | lib/test_prof/tag_prof/printers/html.rb | # frozen_string_literal: true
module TestProf::TagProf
module Printers
module HTML # :nodoc: all
TEMPLATE = "tagprof.template.html"
OUTPUT_NAME = "tag-prof.html"
class << self
include TestProf::Logging
def dump(result)
path = TestProf::Utils::HTMLBuilder.generate(
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_default/fabrication_patch.rb | lib/test_prof/factory_default/fabrication_patch.rb | # frozen_string_literal: true
module TestProf
module FactoryDefault # :nodoc: all
module FabricationPatch
module DefaultExt
def create_default(name, overrides = {}, &block)
obj = ::Fabricate.create(name, overrides, &block)
set_fabricate_default(name, obj)
end
de... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_default/factory_bot_patch.rb | lib/test_prof/factory_default/factory_bot_patch.rb | # frozen_string_literal: true
require "test_prof/factory_bot"
module TestProf
module FactoryDefault # :nodoc: all
module FactoryBotPatch
if defined?(TestProf::FactoryBot::FactoryRunner)
module RunnerExt
refine TestProf::FactoryBot::FactoryRunner do
attr_reader :name, :traits,... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/stack_prof/rspec.rb | lib/test_prof/stack_prof/rspec.rb | # frozen_string_literal: true
require "test_prof/utils/rspec"
module TestProf
module StackProf
# Reporter for RSpec to profile specific examples with StackProf
class Listener # :nodoc:
class << self
attr_accessor :report_name_generator
end
self.report_name_generator = Utils::RSpec... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/ext/active_record_refind.rb | lib/test_prof/ext/active_record_refind.rb | # frozen_string_literal: true
module TestProf
module Ext
# Adds `ActiveRecord::Base#refind` method (through refinement)
module ActiveRecordRefind
refine ActiveRecord::Base do
# Returns new reloaded record.
#
# Unlike `reload` this method returns
# completely re-initializ... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/ext/string_parameterize.rb | lib/test_prof/ext/string_parameterize.rb | # frozen_string_literal: true
module TestProf
# Extend String with #parameterize method
module StringParameterize
refine String do
# Replaces special characters in a string with dashes.
def parameterize(separator: "-", preserve_case: false)
gsub(/[^a-z0-9\-_]+/i, separator).tap do |str|
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/ext/float_duration.rb | lib/test_prof/ext/float_duration.rb | # frozen_string_literal: true
module TestProf
# Extend Float with #duration method
module FloatDuration
refine Float do
def duration
t = self
format("%02d:%02d.%03d", t / 60, t % 60, t.modulo(1) * 1000)
end
end
end
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/ext/factory_bot_strategy.rb | lib/test_prof/ext/factory_bot_strategy.rb | # frozen_string_literal: true
module TestProf
# FactoryBot 5.0 uses strategy classes for associations,
# older versions and top-level invocations use Symbols.
#
# This Refinement should be used FactoryRunner patches to check
# that strategy is :create.
module FactoryBotStrategy
refine Symbol do
d... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/ext/string_truncate.rb | lib/test_prof/ext/string_truncate.rb | # frozen_string_literal: true
module TestProf
# Extend String with #truncate method
module StringTruncate
refine String do
# Truncate to the specified limit
# by replacing middle part with dots
def truncate(limit = 30)
return self unless size > limit
head = ((limit - 3) / 2)
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/ext/array_bsearch_index.rb | lib/test_prof/ext/array_bsearch_index.rb | # frozen_string_literal: true
module TestProf
# Ruby 2.3 #bsearch_index method (for usage with older Rubies)
# Straightforward and non-optimal implementation,
# just for compatibility
module ArrayBSearchIndex
refine Array do
def bsearch_index(&block)
el = bsearch(&block)
index(el)
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_prof/fabrication_patch.rb | lib/test_prof/factory_prof/fabrication_patch.rb | # frozen_string_literal: true
module TestProf
module FactoryProf
# Wrap #run method with FactoryProf tracking
module FabricationPatch
def create(name, overrides = {})
variation = ""
if FactoryProf.config.include_variations? && !overrides.empty?
variation += overrides.keys.sor... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_prof/nate_heckler.rb | lib/test_prof/factory_prof/nate_heckler.rb | # frozen_string_literal: true
require "test_prof/factory_prof"
# A standalone Factory Prof printer which is meant to be always enabled
TestProf::FactoryProf.patch!
started_at = TestProf.now
at_exit do
TestProf::FactoryProf::Printers::NateHeckler.dump(
TestProf::FactoryProf.result, start_time: started_at
)
e... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_prof/factory_bot_patch.rb | lib/test_prof/factory_prof/factory_bot_patch.rb | # frozen_string_literal: true
module TestProf
module FactoryProf
# Wrap #run method with FactoryProf tracking
module FactoryBotPatch
def run(strategy = @strategy)
variation = ""
if FactoryProf.config.include_variations?
if @traits || @overrides
unless @traits.empt... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_prof/printers/flamegraph.rb | lib/test_prof/factory_prof/printers/flamegraph.rb | # frozen_string_literal: true
require "test_prof/utils/html_builder"
module TestProf::FactoryProf
module Printers
module Flamegraph # :nodoc: all
TEMPLATE = "flamegraph.template.html"
OUTPUT_NAME = "factory-flame.html"
class << self
include TestProf::Logging
def dump(result, ... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_prof/printers/json.rb | lib/test_prof/factory_prof/printers/json.rb | # frozen_string_literal: true
require "test_prof/ext/float_duration"
module TestProf::FactoryProf
module Printers
module Json # :nodoc: all
class << self
using TestProf::FloatDuration
include TestProf::Logging
def dump(result, start_time:, **)
return log(:info, "No fact... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_prof/printers/simple.rb | lib/test_prof/factory_prof/printers/simple.rb | # frozen_string_literal: true
require "test_prof/ext/float_duration"
module TestProf::FactoryProf
module Printers
module Simple # :nodoc: all
class << self
using TestProf::FloatDuration
include TestProf::Logging
def dump(result, start_time:, threshold:, truncate_names:)
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_prof/printers/nate_heckler.rb | lib/test_prof/factory_prof/printers/nate_heckler.rb | # frozen_string_literal: true
require "test_prof/ext/float_duration"
module TestProf::FactoryProf
module Printers
# See https://twitter.com/nateberkopec/status/1389945187766456333
module NateHeckler # :nodoc: all
class << self
using TestProf::FloatDuration
include TestProf::Logging
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_prof/factory_builders/fabrication.rb | lib/test_prof/factory_prof/factory_builders/fabrication.rb | # frozen_string_literal: true
require "test_prof/factory_prof/fabrication_patch"
module TestProf
module FactoryProf
module FactoryBuilders
# implementation of #patch and #track methods
# to provide unified interface for all factory-building gems
class Fabrication
# Monkey-patch Fabrica... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_prof/factory_builders/factory_bot.rb | lib/test_prof/factory_prof/factory_builders/factory_bot.rb | # frozen_string_literal: true
require "test_prof/factory_prof/factory_bot_patch"
require "test_prof/factory_bot"
require "test_prof/ext/factory_bot_strategy"
module TestProf
module FactoryProf
module FactoryBuilders
# implementation of #patch and #track methods
# to provide unified interface for all... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/any_fixture/dump.rb | lib/test_prof/any_fixture/dump.rb | # frozen_string_literal: true
require "test_prof/any_fixture/dump/digest"
require "set"
module TestProf
module AnyFixture
MODIFY_RXP = /^(INSERT INTO|UPDATE|DELETE FROM) (\S+)/i.freeze
ANY_FIXTURE_RXP = /(\/\*|--).*\bany_fixture:dump/.freeze
ANY_FIXTURE_IGNORE_RXP = /(\/\*|--).*\bany_fixture:ignore/.fr... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/any_fixture/dsl.rb | lib/test_prof/any_fixture/dsl.rb | # frozen_string_literal: true
if defined?(::ActiveRecord::Base)
require "test_prof/ext/active_record_refind"
using TestProf::Ext::ActiveRecordRefind
end
module TestProf
module AnyFixture
# Adds "global" `fixture`, `before_fixtures_reset` and `after_fixtures_reset` methods (through refinement)
module DSL... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/any_fixture/dump/digest.rb | lib/test_prof/any_fixture/dump/digest.rb | # frozen_string_literal: true
require "digest/sha1"
module TestProf
module AnyFixture
class Dump
module Digest
module_function
def call(*paths)
files = (AnyFixture.config.default_dump_watch_paths + paths).each_with_object([]) do |path_or_glob, acc|
if File.file?(path... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/any_fixture/dump/base_adapter.rb | lib/test_prof/any_fixture/dump/base_adapter.rb | # frozen_string_literal: true
module TestProf
module AnyFixture
class Dump
class BaseAdapter
def reset_sequence!(_table_name, _start)
end
def compile_sql(sql, _binds)
sql
end
def setup_env
end
def teardown_env
end
def imp... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/any_fixture/dump/postgresql.rb | lib/test_prof/any_fixture/dump/postgresql.rb | # frozen_string_literal: true
require "test_prof/any_fixture/dump/base_adapter"
module TestProf
module AnyFixture
class Dump
class PostgreSQL < BaseAdapter
UUID_FUNCTIONS = %w[
gen_random_uuid
uuid_generate_v4
]
def reset_sequence!(table_name, start)
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/any_fixture/dump/sqlite.rb | lib/test_prof/any_fixture/dump/sqlite.rb | # frozen_string_literal: true
require "test_prof/any_fixture/dump/base_adapter"
module TestProf
module AnyFixture
class Dump
class SQLite < BaseAdapter
def reset_sequence!(table_name, start)
execute <<~SQL.chomp
DELETE FROM sqlite_sequence WHERE name=#{table_name}
S... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/event_prof/profiler.rb | lib/test_prof/event_prof/profiler.rb | # frozen_string_literal: true
module TestProf
module EventProf
class Profiler # :nodoc:
attr_reader :event, :total_count, :total_time, :rank_by, :top_count, :per_example,
:time, :count, :example_time, :example_count, :absolute_run_time
alias_method :per_example?, :per_example
def init... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/event_prof/custom_events.rb | lib/test_prof/event_prof/custom_events.rb | # frozen_string_literal: true
module TestProf
module EventProf
# Registers and activates custom events (which require patches).
module CustomEvents
class << self
def register(event, &block)
raise ArgumentError, "Block is required!" unless block
registrations[event] = block
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/event_prof/minitest.rb | lib/test_prof/event_prof/minitest.rb | # frozen_string_literal: true
require "minitest/base_reporter"
require "minitest/event_prof_formatter"
module Minitest
module TestProf
class EventProfReporter < BaseReporter # :nodoc:
def initialize(io = $stdout, options = {})
super
@profiler = configure_profiler(options)
log :inf... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/event_prof/rspec.rb | lib/test_prof/event_prof/rspec.rb | # frozen_string_literal: true
require "test_prof/ext/float_duration"
require "test_prof/ext/string_truncate"
module TestProf
module EventProf
class RSpecListener # :nodoc:
include Logging
using FloatDuration
using StringTruncate
NOTIFICATIONS = %i[
example_group_started
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/event_prof/monitor.rb | lib/test_prof/event_prof/monitor.rb | # frozen_string_literal: true
module TestProf
module EventProf
# Wrap methods with instrumentation
module Monitor
class BaseTracker
attr_reader :event
def initialize(event)
@event = event
end
def track
TestProf::EventProf.instrumenter.instrument(eve... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/event_prof/custom_events/factory_create.rb | lib/test_prof/event_prof/custom_events/factory_create.rb | # frozen_string_literal: true
require "test_prof/factory_bot"
require "test_prof/ext/factory_bot_strategy"
using TestProf::FactoryBotStrategy
TestProf::EventProf::CustomEvents.register("factory.create") do
if defined?(TestProf::FactoryBot) || defined?(Fabricate)
if defined?(TestProf::FactoryBot)
TestProf... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/event_prof/custom_events/sidekiq_inline.rb | lib/test_prof/event_prof/custom_events/sidekiq_inline.rb | # frozen_string_literal: true
TestProf::EventProf::CustomEvents.register("sidekiq.inline") do
if TestProf.require(
"sidekiq/testing",
<<~MSG
Failed to load Sidekiq.
Make sure that "sidekiq" gem is in your Gemfile.
MSG
)
TestProf::EventProf.monitor(
Sidekiq::Client,
"sidekiq... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/event_prof/custom_events/sidekiq_jobs.rb | lib/test_prof/event_prof/custom_events/sidekiq_jobs.rb | # frozen_string_literal: true
TestProf::EventProf::CustomEvents.register("sidekiq.jobs") do
if TestProf.require(
"sidekiq/testing",
<<~MSG
Failed to load Sidekiq.
Make sure that "sidekiq" gem is in your Gemfile.
MSG
)
TestProf::EventProf.monitor(
Sidekiq::Client,
"sidekiq.j... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/event_prof/instrumentations/active_support.rb | lib/test_prof/event_prof/instrumentations/active_support.rb | # frozen_string_literal: true
module TestProf::EventProf
module Instrumentations
# Wrapper over ActiveSupport::Notifications
module ActiveSupport
class Subscriber
attr_reader :block, :started_at
def initialize(block)
@block = block
end
def start(*)
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/rspec_stamp/parser.rb | lib/test_prof/rspec_stamp/parser.rb | # frozen_string_literal: true
require "ripper"
module TestProf
module RSpecStamp
# Parse examples headers
module Parser
# Contains the result of parsing
class Result
attr_accessor :fname, :desc, :desc_const
attr_reader :tags, :htags
def add_tag(v)
@tags ||= []
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/rspec_stamp/rspec.rb | lib/test_prof/rspec_stamp/rspec.rb | # frozen_string_literal: true
module TestProf
module RSpecStamp
class RSpecListener # :nodoc:
include Logging
NOTIFICATIONS = %i[
example_failed
].freeze
def initialize
@failed = 0
@ignored = 0
@total = 0
@examples = Hash.new { |h, k| h[k] = [] }
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/factory_all_stub/factory_bot_patch.rb | lib/test_prof/factory_all_stub/factory_bot_patch.rb | # frozen_string_literal: true
module TestProf
module FactoryAllStub
# Wrap #run method to override strategy
module FactoryBotPatch
def run(_strategy = @strategy)
return super unless FactoryAllStub.enabled?
super(:build_stubbed)
end
end
end
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/ruby_prof/rspec_exclusions.rb | lib/test_prof/ruby_prof/rspec_exclusions.rb | # frozen_string_literal: true
module TestProf
module RubyProf
# Generates the list of RSpec (framework internal) methods
# to exclude from profiling
module RSpecExclusions
module_function
def generate
{
RSpec::Core::Runner => %i[
run
run_specs
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/ruby_prof/rspec.rb | lib/test_prof/ruby_prof/rspec.rb | # frozen_string_literal: true
require "test_prof/utils/rspec"
module TestProf
module RubyProf
# Reporter for RSpec to profile specific examples with RubyProf
class Listener # :nodoc:
class << self
attr_accessor :report_name_generator
end
self.report_name_generator = Utils::RSpec.m... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/ruby_prof/rspec_no_boot.rb | lib/test_prof/ruby_prof/rspec_no_boot.rb | # frozen_string_literal: true
RSpec.configure do |config|
report = nil
config.append_before(:suite) do
report = TestProf::RubyProf.profile(locked: true)
TestProf.log :info, "RubyProf enabled for examples"
end
config.after(:suite) do
report&.dump("examples")
end
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/rspec_dissect/rspec.rb | lib/test_prof/rspec_dissect/rspec.rb | # frozen_string_literal: true
require "test_prof/ext/float_duration"
module TestProf
module RSpecDissect
class Listener # :nodoc:
include Logging
using FloatDuration
NOTIFICATIONS = %i[
example_group_finished
example_finished
].freeze
def initialize
@coll... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/rspec_dissect/collectors/before.rb | lib/test_prof/rspec_dissect/collectors/before.rb | # frozen_string_literal: true
require "test_prof/rspec_dissect/collectors/base"
module TestProf
module RSpecDissect
module Collectors # :nodoc: all
class Before < Base
def initialize(params)
super(name: :before, **params)
end
def print_name
"before(:each)"
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/rspec_dissect/collectors/base.rb | lib/test_prof/rspec_dissect/collectors/base.rb | # frozen_string_literal: true
require "test_prof/utils/sized_ordered_set"
require "test_prof/ext/float_duration"
require "test_prof/ext/string_truncate"
module TestProf # :nodoc: all
using FloatDuration
using StringTruncate
module RSpecDissect
module Collectors
class Base
attr_reader :results... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/lib/test_prof/rspec_dissect/collectors/let.rb | lib/test_prof/rspec_dissect/collectors/let.rb | # frozen_string_literal: true
require "test_prof/rspec_dissect/collectors/base"
module TestProf
module RSpecDissect
module Collectors # :nodoc: all
class Let < Base
def initialize(params)
super(name: :let, **params)
end
def populate!(data)
super
data[... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
rpush/rpush | https://github.com/rpush/rpush/blob/a5ea408d732227c2ed0d23f8a91001d40768152e/bm/bench.rb | bm/bench.rb | ENV['RAILS_ENV'] = 'test'
require 'benchmark'
require 'bundler/setup'
Bundler.require(:default)
require 'stackprof'
$LOAD_PATH.unshift('.')
require 'lib/rpush'
puts "Profiler enabled." if ENV['PROFILE']
class Bench
def self.run
bench = new
yield(bench)
bench._run
end
def initialize
@bms = []
... | ruby | MIT | a5ea408d732227c2ed0d23f8a91001d40768152e | 2026-01-04T15:57:16.574030Z | false |
rpush/rpush | https://github.com/rpush/rpush/blob/a5ea408d732227c2ed0d23f8a91001d40768152e/bm/reflection_benchmark.rb | bm/reflection_benchmark.rb | $LOAD_PATH.unshift('bm')
require 'bench'
n = 1_000_000
Rpush.reflect do |on|
on.error {}
end
Bench.run do |x|
include Rpush::Reflectable
x.report(:reflect) do
n.times do
reflect(:error, nil)
end
end
end
| ruby | MIT | a5ea408d732227c2ed0d23f8a91001d40768152e | 2026-01-04T15:57:16.574030Z | false |
rpush/rpush | https://github.com/rpush/rpush/blob/a5ea408d732227c2ed0d23f8a91001d40768152e/spec/unit_spec_helper.rb | spec/unit_spec_helper.rb | require 'spec_helper'
require 'rails'
# load all shared example files
Dir["./spec/unit/**/shared/**/*.rb"].sort.each { |f| require f }
def unit_example?(metadata)
metadata[:file_path] =~ %r{spec/unit}
end
RSpec.configure do |config|
config.before(:each) do
Modis.with_connection do |redis|
redis.keys('r... | ruby | MIT | a5ea408d732227c2ed0d23f8a91001d40768152e | 2026-01-04T15:57:16.574030Z | false |
rpush/rpush | https://github.com/rpush/rpush/blob/a5ea408d732227c2ed0d23f8a91001d40768152e/spec/functional_spec_helper.rb | spec/functional_spec_helper.rb | require 'spec_helper'
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
def functional_example?(metadata)
metadata[:file_path] =~ %r{/spec/functional/}
end
def timeout(&blk)
Timeout.timeout(10, &blk)
end
RSpec.configure do |config|
config.before(:each) do
Modis.with_connection do |redis|
... | ruby | MIT | a5ea408d732227c2ed0d23f8a91001d40768152e | 2026-01-04T15:57:16.574030Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.