Configuration of IJsonAssertionOptions slows down comparison a log
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- csharp
- 領域
- performance, testing
調査の方向性
JTokenDifferentiator.CompareValues から始め、config.Invoke が値の比較ごとに JsonAssertionOptions を作成する流れを追跡します。大きな JSON ドキュメントと Using callback を使って報告された速度低下を再現し、その後 options のフローを変更した場合の動作を比較します。精度比較を維持しながら、builder の作業の繰り返しを避け、許容可能なパフォーマンスを示せれば完了です。
索引モデルが issue の本文から書いたものです。
説明
To check doubles using precision when comparing JSON's, I am using the following options callback in BeEquivalentTo:
options => options.Using<double>(d => d.Subject.Should().BeApproximately(d.Expectation, 0.001))
.WhenTypeIs<double>()
But it seems that this builder callback is being called for every value comparison.
JTokenDifferentiator.CompareValues contains:
using (var scope = new AssertionScope())
{
actual.Value.Should().BeEquivalentTo(expected.Value, options =>
(JsonAssertionOptions<object>)config.Invoke(new JsonAssertionOptions<object>(options)));
hasMismatches = scope.Discard().Length > 0;
}
With the addition of the Using, a bigger json (MB's) goes from 200ms to +10s on my PC.
As a workaround, I replicated the behavior of the builder by accessing the userEquivalencySteps field on SelfReferenceEquivalencyAssertionOptions using reflection and inserting a custom IEquivalencyStep, instead of using the fluent API.
This brings it to 1s, which is acceptable for my use case.
Would it make sense to not call this options callback for every JSON value and build it once?
Or would adding API to add a custom IEquivalencyStep instead of the builder make sense?
- 主要言語
- C#
- スター
- 73
- フォーク
- 30
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
似ている issue
-
Bug pulumi/pulumi
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
activescott/lessmsi#306 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
HTML sitemap lists unpublished pages対応中かも @KrzysztofPajak が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
grandnode/grandnode2#883 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信