Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrated transformer tool into CLI #4

Merged
merged 8 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@react-native-community/cli-server-api": "^4.10.1",
"@react-native-community/cli-tools": "^4.10.1",
"@react-native-community/cli-types": "^4.10.1",
"@types/source-map": "^0.5.7",
"chalk": "^3.0.0",
"command-exists": "^1.2.8",
"commander": "^2.19.0",
Expand All @@ -59,6 +60,7 @@
"pretty-format": "^25.2.0",
"semver": "^6.3.0",
"serve-static": "^1.13.1",
"source-map": "^0.7.3",
"strip-ansi": "^5.2.0",
"sudo-prompt": "^9.0.0",
"wcwidth": "^1.0.1"
Expand Down
136 changes: 136 additions & 0 deletions packages/cli/src/commands/profile/EventInterfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import {EventsPhase} from './Phases';

export interface SharedEventProperties {
/**
* name of the event
*/
name?: string;
/**
* event category
*/
cat?: string;
/**
* tracing clock timestamp
*/
ts?: number;
/**
* process ID
*/
pid?: number;
/**
* thread ID
*/
tid?: number;
/**
* event type (phase)
*/
ph: EventsPhase;
/**
* id for a stackFrame object
*/
sf?: number;
/**
* thread clock timestamp
*/
tts?: number;
/**
* a fixed color name
*/
cname?: string;
/**
* event arguments
*/
args?: {[key in string]: any};
}

interface DurationEventBegin extends SharedEventProperties {
ph: EventsPhase.DURATION_EVENTS_BEGIN;
}

interface DurationEventEnd extends SharedEventProperties {
ph: EventsPhase.DURATION_EVENTS_END;
}

export type DurationEvent = DurationEventBegin | DurationEventEnd;

export type Event = DurationEvent;

/**
* Each item in the stackFrames object of the hermes profile
*/
export interface HermesStackFrame {
line: string;
column: string;
funcLine: string;
funcColumn: string;
name: string;
category: string;
/**
* A parent function may or may not exist
*/
parent?: number;
}
/**
* Each item in the samples array of the hermes profile
*/
export interface HermesSample {
cpu: string;
name: string;
ts: string;
pid: number;
tid: string;
weight: string;
/**
* Will refer to an element in the stackFrames object of the Hermes Profile
*/
sf: number;
stackFrameData?: HermesStackFrame;
}

/**
* Hermes Profile Interface
*/
export interface HermesCPUProfile {
traceEvents: SharedEventProperties[];
samples: HermesSample[];
stackFrames: {[key in string]: HermesStackFrame};
}

export interface CPUProfileChunk {
id: string;
pid: number;
tid: string;
startTime: number;
nodes: CPUProfileChunkNode[];
samples: number[];
timeDeltas: number[];
}

export interface CPUProfileChunkNode {
id: number;
callFrame: {
line: string;
column: string;
funcLine: string;
funcColumn: string;
name: string;
url?: string;
category: string;
};
parent?: number;
}

export type CPUProfileChunker = {
nodes: CPUProfileChunkNode[];
sampleNumbers: number[];
timeDeltas: number[];
};

export interface SourceMap {
version: string;
sources: string[];
sourceContent: string[];
x_facebook_sources: {names: string[]; mappings: string}[] | null;
names: string[];
mappings: string;
}
30 changes: 30 additions & 0 deletions packages/cli/src/commands/profile/Phases.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export enum EventsPhase {
DURATION_EVENTS_BEGIN = 'B',
DURATION_EVENTS_END = 'E',
COMPLETE_EVENTS = 'X',
INSTANT_EVENTS = 'I',
COUNTER_EVENTS = 'C',
ASYNC_EVENTS_NESTABLE_START = 'b',
ASYNC_EVENTS_NESTABLE_INSTANT = 'n',
ASYNC_EVENTS_NESTABLE_END = 'e',
FLOW_EVENTS_START = 's',
FLOW_EVENTS_STEP = 't',
FLOW_EVENTS_END = 'f',
SAMPLE_EVENTS = 'P',
OBJECT_EVENTS_CREATED = 'N',
OBJECT_EVENTS_SNAPSHOT = 'O',
OBJECT_EVENTS_DESTROYED = 'D',
METADATA_EVENTS = 'M',
MEMORY_DUMP_EVENTS_GLOBAL = 'V',
MEMORY_DUMP_EVENTS_PROCESS = 'v',
MARK_EVENTS = 'R',
CLOCK_SYNC_EVENTS = 'c',
CONTEXT_EVENTS_ENTER = '(',
CONTEXT_EVENTS_LEAVE = ')',
// Deprecated
ASYNC_EVENTS_START = 'S',
ASYNC_EVENTS_STEP_INTO = 'T',
ASYNC_EVENTS_STEP_PAST = 'p',
ASYNC_EVENTS_END = 'F',
LINKED_ID_EVENTS = '=',
}
Loading