For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/lynx-native-api/trace-event.md.
Lynx
  • English
  • TraceEvent

    TraceEvent is a performance instrumentation utility provided by Lynx. Developers can use TraceEvent to flexibly insert trace points in client-side code, recording the execution timing and duration of key functions, tasks, rendering processes, and more.

    Android

    beginSection

    Marks the start of a trace event.

    public static void beginSection(String category, String name)
    public static void beginSection(String category, String name, Map<String, String> args)

    Parameters

    category

    The category of the trace event.

    name

    The name of the trace event.

    args (optional)

    Custom arguments for the trace event.

    Examples

    TraceEvent.beginSection("render", "measure-layout");
    // ... your code ...
    TraceEvent.endSection("render", "measure-layout");
    
    // With custom arguments
    Map<String, String> args = new HashMap();
    args.put("component", "Image");
    args.put("size", "large");
    TraceEvent.beginSection("render", "draw-image", args);
    // ... your code ...
    TraceEvent.endSection("render", "draw-image");

    endSection

    Marks the end of a trace event.

    public static void endSection(String category, String name)

    Parameters

    category

    The category of the trace event.

    name

    The name of the trace event.

    Examples

    TraceEvent.beginSection("logic", "parse-data");
    // ... your code ...
    TraceEvent.endSection("logic", "parse-data");

    instant

    Marks an instant trace event.

    public static void instant(String category, String name)
    public static void instant(String category, String name, Map<String, String> args)

    Parameters

    category

    The category of the trace event.

    name

    The name of the trace event.

    args(optional)

    Custom arguments for the trace event.

    Examples

    TraceEvent.instant("network", "request-started");
    
    // With custom arguments
    Map<String, String> args = new HashMap<>();
    args.put("url", "https://example.com");
    args.put("method", "GET");
    TraceEvent.instant("network", "request-finished", args);

    iOS

    beginSection

    Marks the start of a trace event.

    + (void)beginSection:(NSString *)category withName:(NSString *)name
    + (void)beginSection:(NSString *)category withName:(NSString *)name debugInfo:(NSDictionary *)args

    Parameters

    category

    The category of the trace event.

    name

    The name of the trace event.

    args(optional)

    Custom arguments for the trace event.

    Examples

    [LynxTraceEvent beginSection:@"render" withName:@"measure-layout"];
    // ... your code ...
    [LynxTraceEvent endSection:@"render" withName:@"measure-layout"];
    
    // With custom arguments
    [LynxTraceEvent beginSection:@"render" withName:@"draw-image" debugInfo:@{@"component": @"Image", @"size": @"large"}];
    // ... your code ...
    [LynxTraceEvent endSection:@"render" withName:@"draw-image"];

    endSection

    Marks the end of a trace event.

    + (void)endSection:(NSString *)category withName:(NSString *)name

    Parameters

    category

    The category of the trace event.

    name

    The name of the trace event.

    Examples

    [LynxTraceEvent beginSection:@"logic" withName:@"parse-data"];
    // ... your code ...
    [LynxTraceEvent endSection:@"logic" withName:@"parse-data"];

    instant

    Marks an instant trace event.

    + (void)instant:(NSString *)category withName:(NSString *)name
    + (void)instant:(NSString *)category withName:(NSString *)name debugInfo:(NSDictionary *)args

    Parameters

    category

    The category of the trace event.

    name

    The name of the trace event.

    args(optional)

    Custom arguments for the trace event.

    Examples

    [LynxTraceEvent instant:@"network" withName:@"request-started"];
    // With custom arguments
    [LynxTraceEvent instant:@"network" withName:@"request-finished" debugInfo:@{@"url": @"https://example.com", @"method": @"GET"}];

    Harmony

    beginSection

    Marks the start of a trace event.

    static void beginSection(traceCategory: TraceCategory, name: string, args?: Record<string, string>)

    Parameters

    category

    The category of the trace event.

    export enum TraceCategory {
      Lynx = 'lynx',
      Vitals = 'vitals',
      Other = 'other'
    }
    name

    The name of the trace event.

    args (optional)

    Custom arguments for the trace event.

    Examples

    TraceEvent.beginSection(TraceCategory.Other, "measure-layout");
    // ... your code ...
    TraceEvent.endSection(TraceCategory.Other, "measure-layout");
    
    // With custom arguments
    const args: Record<string, string> = {
      "src": "https://example.com",
      "size": "large"
    }
    TraceEvent.beginSection(TraceCategory.Other, "draw-image", args);
    // ... your code ...
    TraceEvent.endSection(TraceCategory.Other, "draw-image");

    endSection

    Marks the end of a trace event.

    static void endSection(traceCategory: TraceCategory, name: string)

    Parameters

    category

    The category of the trace event.

    export enum TraceCategory {
      Lynx = 'lynx',
      Vitals = 'vitals',
      Other = 'other'
    }
    name

    The name of the trace event.

    Examples

    TraceEvent.beginSection(TraceCategory.Other, "parse-data");
    // ... your code ...
    TraceEvent.endSection(TraceCategory.Other, "parse-data");

    instant

    Marks an instant trace event.

    static instant(traceCategory: TraceCategory, name: string, args?: Record<string, string>)

    Parameters

    category

    The category of the trace event.

    name

    The name of the trace event.

    args(optional)

    Custom arguments for the trace event.

    Examples

    TraceEvent.instant(TraceCategory.Other, "request-started");
    
    // With custom arguments
    const args: Record<string, string> = {
      "url": "https://example.com",
      "method": "GET"
    }
    TraceEvent.instant(TraceCategory.Other, "request-finished", args);

    Desktop (C API)

    Desktop public embedder API exposes trace helpers through C API macros.

    beginSection

    Marks the start of a trace section. It must be paired with LYNX_CAPI_TRACE_END using the same category and name.

    LYNX_CAPI_TRACE_BEGIN(category, name);

    endSection

    Marks the end of a trace section.

    LYNX_CAPI_TRACE_END(category, name);

    instant

    Records an instant trace event.

    LYNX_CAPI_TRACE_INSTANT(category, name);

    counter

    Records a counter trace event.

    LYNX_CAPI_TRACE_COUNTER(category, name, value, incremental);

    Examples

    void DecodeImage() {
      LYNX_CAPI_TRACE_BEGIN("image", "DecodeImage");
      // ... your code ...
      LYNX_CAPI_TRACE_END("image", "DecodeImage");
    }
    
    LYNX_CAPI_TRACE_INSTANT("network", "RequestStarted");
    LYNX_CAPI_TRACE_COUNTER("cache", "EntryCount", 42, false);

    Compatibility

    LCD tables only load in the browser

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.