Skip to content

Conversation

@Jdpf28
Copy link

@Jdpf28 Jdpf28 commented Nov 23, 2025

Description

This PR adds a fully optional performance profiling layer to the WooCommerce iOS app.

The goal is to give maintainers and contributors a clean, isolated and reusable way to:

  • Emit os_signpost events for Instruments.
  • Run repeatable UI performance tests on common user flows.
  • Experiment with background image decoding via an opt-in cache.

What this PR does

  • Adds PerformanceLogger

    • File: WooCommerce/Classes/Profiling/PerformanceLogger.swift
    • Central helper around os_signpost with several predefined categories (catalog load, image decode, cart / checkout, etc.).
    • Self-contained and only used when explicitly called.
    • Does not change any existing behavior by default.
  • Adds OptimizedImageCache (optional micro-optimization)

    • File: WooCommerce/Classes/Profiling/OptimizedImageCache.swift
    • Background image decoding on a dedicated queue, storing fully decoded UIImages in an NSCache.
    • Exposed via a simple image(for:sourceProvider:completion:) API.
    • Not wired into existing views – can be adopted incrementally where appropriate.
  • Adds UI performance tests

    • File: WooCommerce/WooCommerceUITests/Performance/PerformanceUITests.swift
    • Five scenarios using XCTMetric:
      • Browsing the product catalog.
      • Adding products to cart.
      • Completing checkout.
      • Image loading stress test.
      • Cold start performance.
    • Designed to be safe to run locally or in CI.
  • Adds a profiling helper script

    • File: Scripts/profiling/run_profiling.sh
    • Optional script to:
      • Build the app and UI tests.
      • Run selected performance scenarios on a simulator.
      • Organize results under profiling_results/<timestamp>/.
  • Updates .gitignore

    • Ignores profiling_results/ to avoid committing trace bundles and profiling artifacts.

Why it’s safe

  • Only new files plus a minimal .gitignore update.
  • No existing controllers, views or models are modified.
  • No changes to build settings, dependencies or user-facing behavior.
  • All profiling utilities live under dedicated Profiling / Performance groups and are completely opt-in.

Test Steps

To validate this change:

  1. Build the app and tests

    • Open WooCommerce.xcworkspace in Xcode.
    • Select the WooCommerce scheme.
    • Run Product → Build and confirm it succeeds.
    • Select the WooCommerceUITests scheme and build as well.
  2. Run a performance UI test from Xcode

    • With the WooCommerceUITests scheme selected:
    • In the Test navigator, locate PerformanceUITests.
    • Run, for example, testScenario1_BrowseProductCatalog on an iOS Simulator (e.g. iPhone 15).
    • Confirm the test passes and metrics are reported.
  3. (Optional) Run all scenarios via the script

    • From the project root:
      • Ensure the script is executable:
        chmod +x Scripts/profiling/run_profiling.sh
      • Run:
        ./Scripts/profiling/run_profiling.sh all
    • Verify that:
      • The run completes without errors.
      • A new folder is created under profiling_results/<timestamp>/ containing traces / logs.

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.

1 participant