Skip to content

Comments

Improve Unit Layer Performance#272

Merged
1brucben merged 1 commit intov0.3.0from
unitlayerperf
Feb 23, 2026
Merged

Improve Unit Layer Performance#272
1brucben merged 1 commit intov0.3.0from
unitlayerperf

Conversation

@1brucben
Copy link
Owner

This pull request introduces performance benchmarking tests for both the legacy UnitLayer and the new, optimized UnitLayerV2, and updates the main game renderer to use UnitLayerV2 instead of the original implementation. The new tests use a shared harness and extensive mocking to enable reliable comparison of rendering performance in a jsdom environment. These changes lay the groundwork for evaluating and validating improvements made in UnitLayerV2.

Unit layer optimization and integration:

  • The main game renderer (GameRenderer.ts) now uses UnitLayerV2 in place of the legacy UnitLayer, ensuring that all gameplay rendering benefits from the new optimizations. [1] [2]

Performance benchmarking:

  • Added UnitLayerV2.perf.test.ts and UnitLayer.perf.test.ts to benchmark both the optimized and baseline unit layer implementations using a shared harness. These tests use identical scenarios and extensive mocks to ensure fair and consistent performance comparisons. [1] [2]

Testing infrastructure improvements:

  • Both benchmarks include polyfills for browser APIs (such as ImageData and createImageBitmap) and mock out heavy dependencies (like PIXI.js, image imports, and utility modules) to allow performance tests to run in a jsdom environment without requiring real browser or WebGL features. [1] [2]

- Introduced a new benchmark harness for measuring the performance of various Layer implementations that render mobile units.
- Implemented utility functions for creating mock game states, units, and GPU counters.
- Added scenarios for benchmarking including full redraw, tick and render, and unit movement simulations.
- Provided presets for unit mixes to simulate realistic game scenarios.
- Included detailed statistics computation for benchmarking results.
@1brucben 1brucben self-assigned this Feb 23, 2026
@El-Magico777 El-Magico777 added this to the v0.3.0 milestone Feb 23, 2026
@El-Magico777 El-Magico777 linked an issue Feb 23, 2026 that may be closed by this pull request
@El-Magico777 El-Magico777 added the enhancement New feature or request label Feb 23, 2026
@1brucben 1brucben merged commit eacfb94 into v0.3.0 Feb 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit Layer performance

2 participants