Skip to content

🧪 Currency — Diagnostics

Namespace: RevGaming.RevFramework.Samples.Currency.Diagnostics

This folder contains diagnostic-only performance smoke tests for the Currency system.

These scripts are designed to help developers profile mutation patterns and usage behaviour in real Unity scenes.

They are not gameplay systems, not part of the public API, and not performance guarantees.


🎯 Purpose

  • Provide quick, reproducible ways to stress the Currency system
  • Help identify performance bottlenecks in real-world usage
  • Demonstrate how mutation frequency and event fanout affect cost
  • Encourage profiling with real data instead of assumptions

🧩 What Lives Here

CurrencyMutationPerfSmoke

A runtime diagnostic tool that:

  • Spawns multiple wallet owners
  • Repeatedly performs currency mutations:
  • Credit
  • Debit
  • SetBalance
  • Transfer
  • Measures:
  • execution time
  • average cost per call
  • managed-thread allocation deltas
  • Optionally simulates event fanout using dummy listeners

🧠 What These Tests Show

These diagnostics help answer questions like:

  • How expensive are currency mutations under load?
  • Does performance scale across many owners?
  • How much do listeners (OnWalletChanged) cost?
  • Is the system allocating memory during normal usage?

🚫 What These Tests Do NOT Prove

These scripts do not:

  • Provide benchmark guarantees
  • Represent performance in your final game
  • Account for UI, animation, audio, networking, or persistence cost
  • Replace the Unity Profiler

They are smoke tests, not benchmarks.


🕹️ How to Use

  1. Create an empty scene
  2. Add a currency service (e.g. via bootstrap)
  3. Add CurrencyMutationPerfSmoke to a GameObject
  4. Enter Play Mode
  5. Observe Console output and Unity Profiler

Recommended workflow:

  • Start with DummyListeners = 0 (baseline)
  • Increase listener count to simulate UI / event load
  • Toggle spread vs single-owner modes
  • Profile in the Unity Profiler for deeper analysis

⚠️ Gotchas

  • These scripts intentionally stress the system — expect high call volumes
  • Running in the Editor introduces noise — always validate in builds if needed
  • Results are affected by:
  • scene complexity
  • active listeners
  • other systems running in Update
  • Large spikes are often Unity/editor noise, not framework issues

💡 Best Practices

  • Treat these as diagnostic tools, not production systems
  • Use them to identify misuse patterns, not absolute limits
  • Keep mutation frequency reasonable in gameplay code
  • Be mindful of event subscribers — they often cost more than the mutation itself

🧹 Safe to Delete

This folder is sample-only.

You can safely delete it without affecting:

  • runtime systems
  • public API
  • core currency behaviour

🏁 Summary

These diagnostics exist to answer one question:

“Is the Currency system the bottleneck — or is my usage?”

In most cases, they’ll show:

The system is fast.
What you build on top of it determines the cost.