Todos los productos
Search
Centro de documentos

Mobile Platform as a Service:Agregar registros de rendimiento

Última actualización: Sep 05, 2026

Los registros de rendimiento recopilan estadísticas sobre la velocidad de inicio de la aplicación, los tartamudeos y los bloqueos. Consulte las métricas de velocidad de inicio en la página Basic Analysis de la consola de Mobile Analysis Service, así como los informes de tartamudeos y bloqueos en la página Performance Analytics.

La instrumentación de registros es compatible tanto con frameworks mPaaS como con proyectos nativos.

Basado en el framework mPaaS

  1. De forma predeterminada, el monitoreo de tartamudeos está habilitado para el 10 % de los dispositivos. Use la siguiente interfaz para establecer la tasa de monitoreo de tartamudeos.

    [MPAnalysisHelper setLagMonitorPercent: 100]; // Sets monitoring to 100%. This must be set before calling startPerformanceMonitor.

    El monitoreo de tartamudeos solo se habilita en dispositivos físicos y no funciona en el modo de depuración de Xcode.

  2. Al iniciar, llame al método [MPAnalysisHelper startPerformanceMonitor]. Coloque esta llamada dentro del método -(void)application:(UIApplication *)application beforeDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions.

    Start performance monitoring

Para proyectos nativos

El SDK proporciona interfaces de monitoreo de rendimiento. Para usarlas, llame a [PerformanceHelper performanceMonitor] en el método - (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions de su AppDelegate.

    #import "PerformanceHelper.h"
    #import <MPAnalysis/MPAnalysisHelper.h>

    static NSTimeInterval __start_timestamp = 0;

    @implementation PerformanceHelper

    + (void)load
    {
        __start_timestamp = CFAbsoluteTimeGetCurrent();
    }

    + (void)performanceMonitor
    {
        // Start performance monitor.

       [MPAnalysisHelper setLagMonitorPercent: 100]; // Sets monitoring to 100%. This must be set before calling startPerformanceMonitor.
        [MPAnalysisHelper startPerformanceMonitor];

        // Record the time interval used for app startup.
        NSTimeInterval time = CFAbsoluteTimeGetCurrent() - __start_timestamp;
        [[MPAnalysisHelper sharedInstance] writeLogForStartupWithTime:time];

    }

    @end

El monitoreo de tartamudeos solo se habilita en dispositivos físicos y no funciona en el modo de depuración de Xcode.

Personalizar umbrales de monitoreo de rendimiento

Si los valores predeterminados no satisfacen sus necesidades, personalice los umbrales de monitoreo de rendimiento.

Establezca el umbral de tartamudeo

#Import the header file.
#import <MPMasAdapter/MPAnalysisHelper.h>

/**
 Sets the threshold for main thread stuttering monitoring. The unit is seconds. This is optional. The default value is 2 seconds.
 */
+ (void)setLagTimeThreshold:(NSUInteger)threshold;

/**
 Sets the interval for stuttering detection. The value of lagTimeThreshold / lagCheckInterval should be an integer.
 */
+ (void)setLagCheckInterval:(NSTimeInterval)interval;

Establezca el umbral de bloqueo

#import <MPMasAdapter/MPMasSettings.h>

#Create an MPMasSettings category and override the following methods to customize.

/**
 Gets the freeze duration threshold. To customize, override this in the Category. The value of anrTimeThreshold / anrCheckInterval should be an integer.
 */
- (NSUInteger)anrTimeThreshold
{
    return custom_duration;
}

/**
 Gets the freeze detection interval. To customize, override this in the Category. The value of anrTimeThreshold / anrCheckInterval should be an integer.
 */
- (NSTimeInterval)anrCheckInterval
{
    return custom_detection_interval;
}

Establezca el umbral de duración de bloqueo al inicio

#import <MPMasAdapter/MPMasSettings.h>

#Create an MPMasSettings category and override the following method to customize.

/**
 Gets the startup freeze time threshold. To customize, override this in the Category.
 */
- (NSUInteger)startupAnrTimeThreshold
{
    return custom_duration;
}