Skip to content

Conversation

@Stivo182
Copy link
Owner

@Stivo182 Stivo182 commented Apr 30, 2025

Summary by CodeRabbit

  • New Features
    • Added support for percentile columns in benchmark reports, allowing users to include columns for specific percentiles (e.g., 10th, 80th) or a set of default percentiles.
  • Bug Fixes
    • Ensured that adding the same column multiple times only results in a single column in the report.
  • Tests
    • Introduced new tests to verify correct handling and reporting of percentile columns, including duplicates and default sets.

@coderabbitai
Copy link

coderabbitai bot commented Apr 30, 2025

Walkthrough

This change introduces comprehensive support for percentile columns in benchmark reports. A new module implements the logic for creating, identifying, and extracting values for percentile-based columns. The configuration, report builder, and annotation extraction logic are updated to recognize and handle percentile columns, including support for default and custom percentile values. Mathematical quantile calculation is added, and the benchmark statistics class is extended to provide quantile values. Tests are expanded to cover percentile column scenarios and duplicate column handling. Fixture and sample files are updated to demonstrate and validate the new percentile column functionality.

Changes

File(s) Change Summary
src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковПроцентиль.os New module implementing creation, identification, and value extraction for percentile columns; supports default/custom percentiles, helper functions, and uses quantile logic.
src/BenchmarkOneScript/core/Классы/СтатистикаБенчмарка.os Adds ordered timings storage and exported quantile function for percentile calculations.
src/BenchmarkOneScript/core/Модули/МатематическиеФункцииБенчмарков.os Adds exported quantile calculation function.
src/BenchmarkOneScript/core/Модули/КолонкиОтчетаБенчмарков.os Adds exported percentile column identifier and functions to create/get percentile columns.
src/BenchmarkOneScript/core/Классы/КонфигурацияБенчмарков.os Changes column addition to store column names directly instead of resolved objects.
src/BenchmarkOneScript/core/Классы/ПостроительОтчетаБенчмарков.os Modifies column addition order, adds procedure to handle percentile columns in reports.
src/BenchmarkOneScript/core/Модули/ИзвлекательКонфигурацииБенчмарков.os Refactors annotation extraction to support percentile columns and default percentiles.
samples/api/ДобавлениеКолонкиОтчетаПример.os Adds 33rd percentile column to benchmark config; disables static analysis warnings.
samples/benchmarks/Классы/БенчмаркКолонкиОтчета.os Adds reference to percentile column type in sample columns.
tests/fixtures/Классы/БенчмаркиСКолонками.os Adds percentile column reference in test fixture.
tests/ТестыКонфигурации.os Adds tests for duplicate columns, percentile columns (explicit, default, combined), and updates formatting in existing tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Config
    participant AnnotationExtractor
    participant ReportBuilder
    participant PercentileColumnModule
    participant BenchmarkStats
    participant MathFunctions

    User->>Config: Add percentile column(s)
    Config->>AnnotationExtractor: Read column annotations
    AnnotationExtractor->>PercentileColumnModule: Create percentile columns (default/custom)
    Config->>ReportBuilder: Build report with columns
    ReportBuilder->>PercentileColumnModule: For each percentile column, get value
    PercentileColumnModule->>BenchmarkStats: Get quantile for percentile
    BenchmarkStats->>MathFunctions: Calculate quantile value
    MathFunctions-->>BenchmarkStats: Return quantile
    BenchmarkStats-->>PercentileColumnModule: Return value
    PercentileColumnModule-->>ReportBuilder: Return value
    ReportBuilder-->>User: Report with percentile columns
Loading

Poem

In the meadow of code where benchmarks bloom,
Percentiles now dance, dispelling the gloom.
With quantiles calculated and columns anew,
Reports are more clever, statistics in view.
Tests hop along, fixtures join in the fun—
This rabbit’s quite proud of what we’ve just done!
🥕✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f496aa and a371222.

📒 Files selected for processing (11)
  • samples/api/ДобавлениеКолонкиОтчетаПример.os (2 hunks)
  • samples/benchmarks/Классы/БенчмаркКолонкиОтчета.os (1 hunks)
  • src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковПроцентиль.os (1 hunks)
  • src/BenchmarkOneScript/core/Классы/КонфигурацияБенчмарков.os (1 hunks)
  • src/BenchmarkOneScript/core/Классы/ПостроительОтчетаБенчмарков.os (2 hunks)
  • src/BenchmarkOneScript/core/Классы/СтатистикаБенчмарка.os (3 hunks)
  • src/BenchmarkOneScript/core/Модули/ИзвлекательКонфигурацииБенчмарков.os (2 hunks)
  • src/BenchmarkOneScript/core/Модули/КолонкиОтчетаБенчмарков.os (3 hunks)
  • src/BenchmarkOneScript/core/Модули/МатематическиеФункцииБенчмарков.os (1 hunks)
  • tests/fixtures/Классы/БенчмаркиСКолонками.os (1 hunks)
  • tests/ТестыКонфигурации.os (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: build (windows-latest, dev)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build (macos-latest, dev)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (ubuntu-latest, dev)
  • GitHub Check: build (ubuntu-latest, stable)
  • GitHub Check: build (windows-latest, dev)
  • GitHub Check: build (ubuntu-latest, stable)
  • GitHub Check: build (ubuntu-latest, dev)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (macos-latest, dev)
🔇 Additional comments (33)
tests/fixtures/Классы/БенчмаркиСКолонками.os (1)

5-5: Correctly implemented percentile column reference

The addition of the percentile column reference with parameters (10, 80) effectively demonstrates the new functionality, providing test coverage for custom percentile values.

samples/api/ДобавлениеКолонкиОтчетаПример.os (2)

1-2: Appropriate linter suppressions for sample code

The static analysis directives correctly disable warnings for magic numbers and commented code, which is reasonable for sample code demonstrating specific functionality.


12-13: Well-documented percentile column usage examples

Good example showing both how to add a specific percentile (33rd) and a commented reference to default percentiles. This clearly demonstrates the API usage for the new feature.

samples/benchmarks/Классы/БенчмаркКолонкиОтчета.os (1)

5-5: Properly declared percentile column type

The new percentile column reference is correctly added alongside the existing column references, maintaining consistency with the established pattern.

src/BenchmarkOneScript/core/Классы/КонфигурацияБенчмарков.os (1)

479-479: Correctly modified column addition mechanism

The change appropriately modifies how columns are added to the internal collection, now directly adding the column value rather than retrieving it from a global dictionary. This supports the dynamic creation of percentile columns.

src/BenchmarkOneScript/core/Классы/СтатистикаБенчмарка.os (3)

18-18: Well-structured addition of ordered measurements storage.

The new private variable provides necessary state for quantile-based calculations, which is essential for percentile column support.


40-49: Clean implementation of quantile calculation.

This exported function neatly delegates the actual calculation to a specialized mathematical module while maintaining good encapsulation by using the stored ordered measurements.


83-84: Proper initialization of ordered measurements.

The timing measurements are correctly assigned to the new private variable after extraction, ensuring they're available for quantile calculations.

src/BenchmarkOneScript/core/Модули/МатематическиеФункцииБенчмарков.os (1)

151-170: Mathematically sound quantile implementation.

The quantile function implementation is robust with:

  • Proper position calculation using standard formula Probability * (Count - 1)
  • Edge case handling for values outside the range
  • Linear interpolation for positions between array elements

This approach is commonly used in statistical libraries and provides accurate percentile values.

src/BenchmarkOneScript/core/Классы/ПостроительОтчетаБенчмарков.os (2)

53-55: Logical reordering and addition of percentile columns.

The column ordering changes improve report structure by grouping similar statistics together, and the new call to add percentile columns is placed at an appropriate position in the sequence.

Also applies to: 59-59


152-158: Concise implementation for adding percentile columns.

The implementation follows established patterns in the codebase by iterating through columns created by the specialized percentile module and adding each to the report structure.

src/BenchmarkOneScript/core/Модули/КолонкиОтчетаБенчмарков.os (3)

19-19: Consistent addition of percentile column identifier.

The new exported variable follows the established pattern for column identifiers in this module.


77-83: Well-designed integration functions for percentile columns.

These functions provide a clean API for:

  1. Creating percentile columns with specific percentile values
  2. Generating consistent column names for percentiles

The implementation properly delegates to the specialized percentile column module, maintaining separation of concerns.


106-107: Proper constant initialization.

The percentile constant is correctly initialized following the established pattern of the module.

src/BenchmarkOneScript/core/Модули/ИзвлекательКонфигурацииБенчмарков.os (3)

196-199: Clean refactoring of column annotation reading

The procedure ПрочитатьАннотацииКолонок has been refactored to delegate its functionality to two specialized procedures, which improves code organization and maintainability.


201-212: Good extraction of existing functionality

The existing logic for reading fixed column annotations has been moved to this dedicated procedure without modification, maintaining backward compatibility.


214-234: Well-implemented percentile column annotation extraction

The new procedure handles the extraction of percentile columns from annotations effectively. It correctly:

  1. Reads annotations of type "КолонкаПроцентиль"
  2. Extracts percentile values from annotation parameters
  3. Adds the corresponding percentile columns to the configuration
  4. Falls back to a default percentile column when annotations exist but no specific values are provided
tests/ТестыКонфигурации.os (7)

388-390: Improved readability with extracted column initialization

Moving the column list initialization to a separate block improves code organization and readability.


409-411: Consistent code style through column initialization extraction

The same improvement has been applied to this test method, maintaining consistent coding style across similar test methods.


429-448: Effective test for duplicate column handling

This test verifies that adding the same column twice doesn't cause issues, ensuring the system handles duplicate column additions gracefully.


468-488: Comprehensive test for percentile columns from annotations

This test validates that percentile columns specified in annotations are correctly incorporated into the benchmark report, confirming proper integration between the annotation extraction and report generation subsystems.


490-513: Solid test for explicit percentile column addition

This test confirms that manually adding percentile columns with specific values works correctly, which is important for API users who want to add custom percentile columns.


515-534: Essential test for default percentile columns

This test ensures that the default set of percentiles is correctly added when requested. It verifies integration with ПроцентилиПоУмолчанию() and checks that all default percentile columns appear in the report.


536-558: Thorough test for combining default and custom percentiles

This test verifies the important use case of combining default percentile columns with a custom percentile value, ensuring they don't conflict and both sets appear correctly in the report.

src/BenchmarkOneScript/columns/Модули/КолонкаОтчетаБенчмарковПроцентиль.os (9)

1-3: Appropriate library imports

The code correctly imports the necessary libraries: delegate for creating function delegates and fluent for collection processing.


4-21: Well-implemented factory function for percentile columns

The Создать function properly creates a percentile column with appropriate attributes:

  • Standardized naming using the ИмяКолонки helper
  • Clear header format with "P" prefix
  • Descriptive text using string templates
  • Correct unit of measurement (nanoseconds)
  • Delegation to the Значение function for value calculation

23-37: Effective percentile value extraction

The Значение function correctly:

  1. Extracts the percentile value from the column name
  2. Converts it to a ratio (dividing by 100)
  3. Uses the statistics object's Квантиль method to get the actual percentile value

39-85: Robust implementation of multi-column factory

The СоздатьПоИмени function handles all required scenarios:

  • Processing single column names or arrays of column names
  • Identifying valid percentile column names
  • Handling default percentile sets when requested
  • Extracting specific percentile values from column names
  • Ensuring percentile values are unique and sorted
  • Creating the appropriate column instances

87-97: Straightforward name generation

The ИмяКолонки function creates a consistent naming pattern for percentile columns by combining the prefix with the percentile value.


98-108: Effective column type detection

The ЭтоИмяКолонки function correctly identifies both generic percentile column names and specific percentile column names by checking for the appropriate prefix.


109-130: Comprehensive default percentile set

The ПроцентилиПоУмолчанию function provides a well-thought-out set of default percentiles that cover common statistical needs:

  • Range boundaries (0th and 100th percentiles)
  • Quartiles (25th, 50th, 75th approximated by 67th and 80th)
  • Common upper percentiles for performance analysis (85th, 90th, 95th)

The suppression of the magic number warning is appropriate here since these are standard statistical values.


132-138: Useful helper functions

The ПроцентильПоКолонке and Префикс functions provide consistent handling of column name parsing and generation.


140-145: Type-safe string to number conversion

The СтрокаВЧисло function properly uses the type description system to safely convert string values to numbers.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Stivo182 Stivo182 merged commit 19f1a51 into main Apr 30, 2025
11 of 13 checks passed
@Stivo182 Stivo182 deleted the feat/percentile branch April 30, 2025 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants