Skip to content

Commit

Permalink
Merge pull request #4 from MLH-Fellowship/test/transformer
Browse files Browse the repository at this point in the history
Integrated transformer tool into CLI
  • Loading branch information
jessieAnhNguyen authored Aug 10, 2020
2 parents defc7b7 + ef6bb10 commit 86c8110
Show file tree
Hide file tree
Showing 9 changed files with 669 additions and 35 deletions.
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

0 comments on commit 86c8110

Please sign in to comment.