Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

HistogramBase.GetValueAtPercentile — Double-Loop When Flat Array Index Is Available

オープン
#145 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
55/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
csharp
領域
performance

調査の方向性

Start in HistogramBase.cs at GetValueAtPercentile and inspect how LongHistogram stores its counts, including CountsArrayLength, GetCountAtIndex, and ValueFromIndex. Compare the existing nested scan with the proposed flat traversal; done means percentile lookup preserves the current result while avoiding the nested index mapping.

索引モデルが issue の本文から書いたものです。

説明

agent enhancement

File: HistogramBase.cs

The percentile lookup iterates nested i / j loops over BucketCount × SubBucketCount. Since CountsArrayIndex(bucketIndex, subBucketIndex) maps this to a flat array, and the counts array is already flat in LongHistogram, the entire scan can be done as a single flat loop:

public long GetValueAtPercentile(double percentile)
{
    var countAtPercentile = Math.Max(
        (long)((Math.Min(percentile, 100.0) / 100.0 * TotalCount) + 0.5), 1);
long runningCount = 0;
for (int i = 0; i < CountsArrayLength; i++)
{
    runningCount += GetCountAtIndex(i);
    if (runningCount >= countAtPercentile)
        return HighestEquivalentValue(ValueFromIndex(i));
}
throw new ArgumentOutOfRangeException(...);

}

The nested loop computes GetCountAt(i, j) → GetCountAtIndex(CountsArrayIndex(i, j)) anyway — the flat version eliminates the CountsArrayIndex call per iteration and improves cache locality by accessing memory sequentially.

主要言語
C#
スター
185
フォーク
31
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

HdrHistogram/HdrHistogram.NET のほかの issue

HdrHistogram/HdrHistogram.NET の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。