Skip to content

test: add comprehensive Diagnostics integration tests - #777

Merged
ooples merged 1 commit into
masterfrom
test/diagnostics-integration-tests
Jan 24, 2026
Merged

ooples merged 1 commit into
masterfrom
test/diagnostics-integration-tests

Conversation

@ooples

@ooples ooples commented Jan 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add 98 comprehensive integration tests for the Diagnostics module
  • Tests cover MemoryTracker, ProfilerSession, ProfileReport, and related classes
  • All tests pass on both .NET 10.0 and .NET Framework 4.7.1

Test Coverage

MemoryTracker (24 tests)

  • Enable/disable functionality
  • Snapshot creation and comparison
  • History tracking with configurable size
  • Reset functionality
  • Memory pressure level detection
  • Memory estimation methods

MemorySnapshot & MemoryDiff (12 tests)

  • CompareTo comparisons
  • ToString representations
  • Property validations
  • Allocation rate calculations

ProfilerSession (25 tests)

  • Enable/disable functionality with AutoEnableInDebug handling
  • Scope-based profiling (using/IDisposable pattern)
  • Timer-based profiling (manual start/stop)
  • Reset functionality
  • Report generation
  • Statistics calculation (mean, min, max, percentiles)

ProfileReport (20 tests)

  • JSON export/import
  • CSV export
  • Markdown export
  • Report comparison
  • Operation statistics

Integration Scenarios (17 tests)

  • Memory tracking during allocations
  • Profiling during simulated workloads
  • Combined memory and profiler usage
  • Config validation scenarios

Test Results

.NET 10.0:    Passed: 135, Skipped: 2, Total: 137
.NET 4.7.1:   Passed: 135, Skipped: 0, Total: 135

Fixes #653

🤖 Generated with Claude Code

Add 98 integration tests for the Diagnostics module covering:

MemoryTracker:
- Enable/disable functionality
- Snapshot creation and comparison
- History tracking
- Reset functionality
- Memory pressure level detection
- Memory estimation

ProfilerSession:
- Enable/disable functionality
- Scope-based profiling
- Timer-based profiling
- Reset functionality
- Report generation
- Statistics calculation

ProfileReport:
- JSON/CSV/Markdown export
- Report comparison
- Operation statistics

Integration scenarios:
- Memory tracking during allocations
- Profiling during simulated workloads
- Combined memory and profiler usage

Fixes #653

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jan 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
aidotnet-playground-api Ready Ready Preview, Comment Jan 24, 2026 2:07pm

@coderabbitai

coderabbitai Bot commented Jan 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Tests
    • Added comprehensive integration test suite for diagnostics features, validating memory tracking, profiling sessions, performance statistics generation, report formats, and multi-threaded scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

A comprehensive integration test suite for the Diagnostics module is introduced, validating MemoryTracker, MemorySnapshot, MemoryDiff, MemoryPressureLevel, ProfilerSession, ProfilingConfig, and profiling report generation across multiple formats, statistics computation, profile comparison, and multi-threaded scenarios.

Changes

Cohort / File(s) Summary
Diagnostics Integration Tests
tests/AiDotNet.Tests/IntegrationTests/Diagnostics/DiagnosticsIntegrationTests.cs
New test suite covering memory tracking (enable/disable, snapshots, history, resets, pressure levels), memory estimations (tensor, KV cache), scope tracking, timer operations, profiling reports (JSON, CSV, Markdown, dictionary, string formats), profile comparison and regression detection, statistics (percentiles, min/max, ops per second), sampling configurations, and multi-threaded concurrent profiling scenarios.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~55 minutes

Suggested labels

feature

Poem

🐰 Integration tests so bright and bold,
Diagnostics shine in stories told,
Memory tracked, profiles soar,
Threads dance and threads explore,
Coverage rises more and more! 📊

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding comprehensive Diagnostics integration tests.
Description check ✅ Passed The description is directly related to the changeset, providing detailed breakdown of 98 tests by category, test results, and issue reference.
Linked Issues check ✅ Passed The PR adds comprehensive integration tests for the Diagnostics module covering performance profiling and diagnostic tools, directly addressing issue #653's acceptance criteria.
Out of Scope Changes check ✅ Passed All changes are within scope: a single new test file with 98 integration tests for the Diagnostics module as required by the linked issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/diagnostics-integration-tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added the feature Feature work item label Jan 24, 2026
@sonarqubecloud

Copy link
Copy Markdown

@ooples
ooples merged commit 1aca350 into master Jan 24, 2026
41 checks passed
@ooples
ooples deleted the test/diagnostics-integration-tests branch January 24, 2026 21:23
@coderabbitai coderabbitai Bot mentioned this pull request Jan 24, 2026
3 tasks done
ooples pushed a commit that referenced this pull request Jul 19, 2026
…t NHWC)

Engine.GridSample is uniformly NCHW (PyTorch F.grid_sample convention,
standardized in Tensors #777): both CPU overloads, the GPU override, and
GridSampleGpu all take [N,C,H,W] and return [N,C,outH,outW]. All seven
callers wrongly permuted their image/feature input to NHWC before sampling
(a stale assumption from when the engine was NHWC, flipped by #777), which
re-labelled the H dim as "channels". Most passed loose invariants with
geometrically-wrong warps; BasicVSR++/SpyNet threw IndexOutOfRange at the
degenerate 2x2 pyramid level (3-channel frame warped into 2 "channels").

Fix: pass the channels-first tensor directly; the grid is [B,outH,outW,2]
regardless of image layout, so it is unchanged. SpatialTransformer's CPU
and GPU forward paths are reworked to channels-first (localization reduces
over the channel axis; output permuted to NHWC only for channel-last
callers). SpyNet also drops its redundant private _engine (which pinned it
to CpuEngine) in favour of the base LayerBase.Engine property.

Verified (net10.0, GPU disabled): BasicVSR++ 27/27, FILM 27/27, RIFE 27/27,
UPRNet 27/27, RAFT 27/27, SpyNet 10/10, SpatialTransformer 10/10.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ooples pushed a commit that referenced this pull request Jul 19, 2026
…t NHWC)

Engine.GridSample is uniformly NCHW (PyTorch F.grid_sample convention,
standardized in Tensors #777): both CPU overloads, the GPU override, and
GridSampleGpu all take [N,C,H,W] and return [N,C,outH,outW]. All seven
callers wrongly permuted their image/feature input to NHWC before sampling
(a stale assumption from when the engine was NHWC, flipped by #777), which
re-labelled the H dim as "channels". Most passed loose invariants with
geometrically-wrong warps; BasicVSR++/SpyNet threw IndexOutOfRange at the
degenerate 2x2 pyramid level (3-channel frame warped into 2 "channels").

Fix: pass the channels-first tensor directly; the grid is [B,outH,outW,2]
regardless of image layout, so it is unchanged. SpatialTransformer's CPU
and GPU forward paths are reworked to channels-first (localization reduces
over the channel axis; output permuted to NHWC only for channel-last
callers). SpyNet also drops its redundant private _engine (which pinned it
to CpuEngine) in favour of the base LayerBase.Engine property.

Verified (net10.0, GPU disabled): BasicVSR++ 27/27, FILM 27/27, RIFE 27/27,
UPRNet 27/27, RAFT 27/27, SpyNet 10/10, SpatialTransformer 10/10.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — d4aa9dd8 Deployed Jan 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Feature work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: Add integration tests for Diagnostics module [P3]

2 participants