# Function withPerformanceTracking

- withPerformanceTracking<T>(
  monitor: PerformanceMonitor,
  operation: string,
  fn: () => Promise<T>,
  ): Promise<T>

  Execute an async function and track its performance

  Automatically records the duration of the operation in the provided performance monitor.

  #### Type Parameters

  - T

    Return type of the function

  #### Parameters

  - monitor: PerformanceMonitor

    Performance monitor to record the duration in

  - operation: string

    Operation name for tracking (e.g., `'fetch_meps'`)

  - fn: () => Promise<T>

    Async function to execute and measure

  #### Returns Promise<T>

  Promise that resolves with the function result

  #### Throws

  Re-throws any error thrown by `fn` after recording the duration

  #### Example

      const monitor = new PerformanceMonitor();

      const result = await withPerformanceTracking(
        monitor,
        'fetch_meps',
        async () => {
          return await client.getMEPs({ limit: 100 });
        }
      );

  #### Since

  0.8.0

  - Defined in utils/performance.ts:321