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);
Compatibility
Loading...