diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bed26e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +gemfiles/*.lock diff --git a/.mdlrc b/.mdlrc new file mode 100644 index 0000000..35cd59e --- /dev/null +++ b/.mdlrc @@ -0,0 +1 @@ +rules "~MD013", "~MD033", "~MD034", "~MD026" diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..3adb6e4 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,12 @@ +require: + - standard/cop/semantic_blocks + - rubocop-md + +inherit_gem: + standard: config/base.yml + +Standard/SemanticBlocks: + Enabled: false + +Lint/DuplicateMethods: + Enabled: false diff --git a/README.md b/README.md new file mode 100644 index 0000000..aeb114a --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# TestProfの日本語マニュアル + +[ホームページ](https://test-prof.evilmartians.io/)でご確認ください。 + +## Linters + +We try to keep our documentation both correct and _stylish_ using the following tools: + +- [mdl](https://github.com/markdownlint/markdownlint) (Markdown linter, Ruby edition) +- RuboCop with [rubocop-md](https://github.com/rubocop-hq/rubocop-md) and [standard](https://github.com/testdouble/standard) (Ruby code snippets style checking) + +### Install `mdl` + +```sh +gem install mdl +``` + +### Install StandardRB and `rubocop-md` + +```sh +gem install standard +gem install rubocop-md +``` diff --git a/docs/_sidebar.md b/docs/_sidebar.md new file mode 100644 index 0000000..21783b2 --- /dev/null +++ b/docs/_sidebar.md @@ -0,0 +1,23 @@ +* [入門](/getting_started.md) + +* 性能解析 + * [RubyProfとの統合](/profilers/ruby_prof.md) + * [StackProfとの統合](/profilers/stack_prof.md) + * [Event Profiler](/profilers/event_prof.md) + * [Tag Profiler](/profilers/tag_prof.md) + * [Factory Doctor](/profilers/factory_doctor.md) + * [Factory Profiler](/profilers/factory_prof.md) + * [RSpecDissect Profiler](/profilers/rspec_dissect.md) + +* レシピー + * [`before_all`](/recipes/before_all.md) + * [`let_it_be`](/recipes/let_it_be.md) + * [AnyFixture](/recipes/any_fixture.md) + * [FactoryDefault](/recipes/factory_default.md) + * [FactoryAllStub](/recipes/factory_all_stub.md) + * [RSpec Stamp](/recipes/rspec_stamp.md) + * [テストのサンプリング](/recipes/tests_sampling.md) + * [Railsのログ出力](/recipes/logging.md) + +* その他 + * [RuboCopのコップ](/misc/rubocop.md) diff --git a/docs/getting_started.md b/docs/getting_started.md new file mode 100644 index 0000000..315cd78 --- /dev/null +++ b/docs/getting_started.md @@ -0,0 +1,67 @@ +# 入門 + +## 前提条件 + +対応しているRubyのバージョン + +* Ruby (MRI) >= 2.5.0 + * Ruby 2.2の場合は、TestProf < 0.7.0、 + * Ruby 2.3の場合は、TestProf ~> 0.7.0、 + * Ruby 2.4の場合は、TestProf < 0.12.0 を使用してください。 + +* JRuby >= 9.1.0.0(一部のツールはバージョン 9.2.7+ が必要) + +RSpecの場合は、対応のバージョンは >=3.5.0 です。もっと古いRSpecには TestProf < 0.8.0 が必要です。 + +## インストール + +ジェム「`test-prof`」を追加してください。 + +```ruby +group :test do + gem "test-prof" +end +``` + +これでインストールが終わりです! + +## 設定 + +TestProfは、全ツールで使用されるいくつかのグローバル設定があります。 + +```ruby +TestProf.configure do |config| + # レポートなどを保存するフォルダー (デフォルトは'tmp/test_prof') + config.output_dir = "tmp/test_prof" + + # レポートファイルの名前ににタイムスタンプを付ける + config.timestamps = true + + # 出力をハイライトする + config.color = true + + # ログ出力の宛先(ファイルまたはSTDOUT) + config.output = $stdout + + # カスタムのロガーインスタンスを指定することもできます + config.logger = MyLogger.new +end +``` + +### レポート区別用の識別子 + +また、「`TEST_PROF_REPORT`」という環境変数を使用して、レポート名に識別子を追加することができます。これは、異なるセットアップでのレポートを比較したい場合に便利です。 + +**例:** `bootsnap`を使う場合と使わない場合のロード時間を[`stackprof`](./profilers/stack_prof.md)で比較してみましょう。 + +```sh +# 一番目のレポートに、「-with-bootsnap」を付けます +$ TEST_STACK_PROF=boot TEST_PROF_REPORT=with-bootsnap bundle exec rake +$ #=> StackProf report generated: tmp/test_prof/stack-prof-report-wall-raw-boot-with-bootsnap.dump + +# 二番目のレポートは、bootnapを無効にし、名前に「-no-bootsnap」を付けて作成します +$ TEST_STACK_PROF=boot TEST_PROF_REPORT=no-bootsnap bundle exec rake +$ #=> StackProf report generated: tmp/test_prof/stack-prof-report-wall-raw-boot-no-bootsnap.dump +``` + +これで、分かりやすい名前の2つのレポートができました。 diff --git a/gemfiles/rubocop.gemfile b/gemfiles/rubocop.gemfile new file mode 100644 index 0000000..9b4cc92 --- /dev/null +++ b/gemfiles/rubocop.gemfile @@ -0,0 +1,4 @@ +source "https://rubygems.org" do + gem "rubocop-md", "~> 0.3" + gem "standard", "~> 0.2.0" +end