Skip to content

Commit

Permalink
Added support for Papyrus profiles (jlfwong#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
xieve authored and jackerghan committed Jul 28, 2023
1 parent 350608d commit 0db20ca
Show file tree
Hide file tree
Showing 6 changed files with 438 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sample/profiles/papyrus/script.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Script_abc_example_quest log opened (PC)
500:PUSH:3053:1:abcExampleQuest (24021278):abc_example_quest..exampleFunction1
1500:POP:3053:1:abcExampleQuest (24021278):abc_example_quest..exampleFunction1
1700:PUSH:3053:2:abcExampleQuest (24021278):abc_example_quest..exampleFunction2
1750:POP:3053:2:abcExampleQuest (24021278):abc_example_quest..exampleFunction2
2000:PUSH:3208:2:abcExampleQuest (24021278):abc_example_quest..exampleFunction3
2000:PUSH:3053:3:None:abc_example_quest..exampleFunction4
2000:POP:3208:2:abcExampleQuest (24021278):abc_example_quest..exampleFunction3
2000:POP:3053:3:None:abc_example_quest..exampleFunction4
2000:PUSH:3947:1:None:abc_example_quest..exampleFunction5
2250:PUSH:3949:1:None:abc_example_quest..exampleFunction6
2500:POP:3949:1:None:abc_example_quest..exampleFunction6
3000:POP:3947:1:None:abc_example_quest..exampleFunction5
3450:PUSH:3947:1:abcExampleQuest (24021278):abc_example_quest..exampleFunction1
3500:POP:3947:1:abcExampleQuest (24021278):abc_example_quest..exampleFunction1
Log closed
24 changes: 24 additions & 0 deletions sample/profiles/papyrus/stack.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Stack_3185 log opened (PC)
50002:START:3185
50002:POP:3185:3:None:Debug..StartStackProfiling
50002:QUEUE_PUSH:3185:3: (00018A56):Location.??.GetFormID
50018:PUSH:3185:3: (00018A56):Form..GetFormID
50018:POP:3185:3: (00018A56):Form..GetFormID
50018:PUSH:3185:3:None:abc_example_mod_quest..exampleFunction1
50018:QUEUE_PUSH:3185:4: (00018A56):Location.??.GetFormID
50035:PUSH:3185:4: (00018A56):Form..GetFormID
50035:POP:3185:4: (00018A56):Form..GetFormID
50035:PUSH:3185:4:None:Game..GetModName
50035:POP:3185:4:None:Game..GetModName
50035:POP:3185:3:None:abc_example_mod_quest..exampleFunction1
50035:POP:3185:2:None:abc_example_mod_quest..exampleFunction2
50035:QUEUE_PUSH:3185:2:WhiterunPLainsDistrict03 (0001A27A):Cell.??.IsInterior
50051:PUSH:3185:2:WhiterunPLainsDistrict03 (0001A27A):Cell..IsInterior
50051:POP:3185:2:WhiterunPLainsDistrict03 (0001A27A):Cell..IsInterior
50051:POP:3185:1:abcExampleModQuest (24021278):abc_example_mod_quest..exampleFunction3
50051:QUEUE_PUSH:3185:1:None:utility.??.WaitMenuMode
50068:PUSH:3185:1:None:utility..WaitMenuMode
50602:POP:3185:1:None:utility..WaitMenuMode
50602:QUEUE_POP:3185:0:None:abc_example_mod_effect..OnEffectStart
50619:POP:3185:0:None:abc_example_mod_effect..OnEffectStart
Log closed
196 changes: 196 additions & 0 deletions src/import/__snapshots__/papyrus.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`importFromPapyrus script profile 1`] = `
Object {
"frames": Array [
Frame {
"col": undefined,
"file": undefined,
"key": "STACK 3053",
"line": undefined,
"name": "STACK 3053",
"selfWeight": 200,
"totalWeight": 1250,
},
Frame {
"col": undefined,
"file": undefined,
"key": "abc_example_quest..exampleFunction1",
"line": undefined,
"name": "abc_example_quest..exampleFunction1",
"selfWeight": 1050,
"totalWeight": 1050,
},
Frame {
"col": undefined,
"file": undefined,
"key": "abc_example_quest..exampleFunction2",
"line": undefined,
"name": "abc_example_quest..exampleFunction2",
"selfWeight": 50,
"totalWeight": 50,
},
Frame {
"col": undefined,
"file": undefined,
"key": "STACK 3208",
"line": undefined,
"name": "STACK 3208",
"selfWeight": 0,
"totalWeight": 0,
},
Frame {
"col": undefined,
"file": undefined,
"key": "abc_example_quest..exampleFunction3",
"line": undefined,
"name": "abc_example_quest..exampleFunction3",
"selfWeight": 0,
"totalWeight": 0,
},
Frame {
"col": undefined,
"file": undefined,
"key": "abc_example_quest..exampleFunction4",
"line": undefined,
"name": "abc_example_quest..exampleFunction4",
"selfWeight": 0,
"totalWeight": 0,
},
Frame {
"col": undefined,
"file": undefined,
"key": "STACK 3947",
"line": undefined,
"name": "STACK 3947",
"selfWeight": 450,
"totalWeight": 1500,
},
Frame {
"col": undefined,
"file": undefined,
"key": "abc_example_quest..exampleFunction5",
"line": undefined,
"name": "abc_example_quest..exampleFunction5",
"selfWeight": 750,
"totalWeight": 1000,
},
Frame {
"col": undefined,
"file": undefined,
"key": "STACK 3949",
"line": undefined,
"name": "STACK 3949",
"selfWeight": 0,
"totalWeight": 250,
},
Frame {
"col": undefined,
"file": undefined,
"key": "abc_example_quest..exampleFunction6",
"line": undefined,
"name": "abc_example_quest..exampleFunction6",
"selfWeight": 250,
"totalWeight": 250,
},
],
"name": "script.log",
"stacks": Array [
"STACK 3053;abc_example_quest..exampleFunction1 1.00s",
"STACK 3053 200.00ms",
"STACK 3053;abc_example_quest..exampleFunction2 50.00ms",
" 250.00ms",
"STACK 3947;abc_example_quest..exampleFunction5 250.00ms",
"STACK 3947;abc_example_quest..exampleFunction5;STACK 3949;abc_example_quest..exampleFunction6 250.00ms",
"STACK 3947;abc_example_quest..exampleFunction5 500.00ms",
"STACK 3947 450.00ms",
"STACK 3947;abc_example_quest..exampleFunction1 50.00ms",
],
}
`;

exports[`importFromPapyrus script profile: indexToView 1`] = `0`;

exports[`importFromPapyrus script profile: profileGroup.name 1`] = `"script.log"`;

exports[`importFromPapyrus stack profile 1`] = `
Object {
"frames": Array [
Frame {
"col": undefined,
"file": undefined,
"key": "STACK 3185",
"line": undefined,
"name": "STACK 3185",
"selfWeight": 66,
"totalWeight": 617,
},
Frame {
"col": undefined,
"file": undefined,
"key": "Debug..StartStackProfiling",
"line": undefined,
"name": "Debug..StartStackProfiling",
"selfWeight": 0,
"totalWeight": 0,
},
Frame {
"col": undefined,
"file": undefined,
"key": "Form..GetFormID",
"line": undefined,
"name": "Form..GetFormID",
"selfWeight": 0,
"totalWeight": 0,
},
Frame {
"col": undefined,
"file": undefined,
"key": "abc_example_mod_quest..exampleFunction1",
"line": undefined,
"name": "abc_example_mod_quest..exampleFunction1",
"selfWeight": 17,
"totalWeight": 17,
},
Frame {
"col": undefined,
"file": undefined,
"key": "Game..GetModName",
"line": undefined,
"name": "Game..GetModName",
"selfWeight": 0,
"totalWeight": 0,
},
Frame {
"col": undefined,
"file": undefined,
"key": "Cell..IsInterior",
"line": undefined,
"name": "Cell..IsInterior",
"selfWeight": 0,
"totalWeight": 0,
},
Frame {
"col": undefined,
"file": undefined,
"key": "utility..WaitMenuMode",
"line": undefined,
"name": "utility..WaitMenuMode",
"selfWeight": 534,
"totalWeight": 534,
},
],
"name": "stack.log",
"stacks": Array [
"STACK 3185 16.00ms",
"STACK 3185;abc_example_mod_quest..exampleFunction1 17.00ms",
"STACK 3185 33.00ms",
"STACK 3185;utility..WaitMenuMode 534.00ms",
"STACK 3185 17.00ms",
],
}
`;

exports[`importFromPapyrus stack profile: indexToView 1`] = `0`;

exports[`importFromPapyrus stack profile: profileGroup.name 1`] = `"stack.log"`;
6 changes: 6 additions & 0 deletions src/import/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {decodeBase64} from '../lib/utils'
import {importFromChromeHeapProfile} from './v8heapalloc'
import {isTraceEventFormatted, importTraceEvents} from './trace-event'
import {importFromCallgrind} from './callgrind'
import {importFromPapyrus} from "./papyrus";

export async function importProfileGroupFromText(
fileName: string,
Expand Down Expand Up @@ -188,6 +189,11 @@ async function _importProfileGroup(dataSource: ProfileDataSource): Promise<Profi
return toGroup(importFromInstrumentsDeepCopy(contents))
}

if (/^(Stack_|Script_|Obj_)\S+ log opened \(PC\)\n/.exec(contents.firstChunk())){
console.log("Importing as Papyrus profile")
return toGroup(importFromPapyrus(contents))
}

const fromLinuxPerf = importFromLinuxPerf(contents)
if (fromLinuxPerf) {
console.log('Importing from linux perf script output')
Expand Down
9 changes: 9 additions & 0 deletions src/import/papyrus.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {checkProfileSnapshot} from '../lib/test-utils'

test('importFromPapyrus script profile', async () => {
await checkProfileSnapshot('./sample/profiles/papyrus/script.log')
})

test('importFromPapyrus stack profile', async () => {
await checkProfileSnapshot('./sample/profiles/papyrus/stack.log')
})
Loading

0 comments on commit 0db20ca

Please sign in to comment.