mirror of
https://github.com/jlfwong/speedscope.git
synced 2024-11-22 12:53:23 +03:00
Allow optional CR before LF when probing collapsed stacks files (#154)
This fixes #152, in that it allows "collapsed stacks" files generated with tools using Windows line endings to be imported into the tool verbatim.
This commit is contained in:
parent
44a1f520fe
commit
281d9f9033
5
sample/profiles/stackcollapse/simple-crlf.txt
Normal file
5
sample/profiles/stackcollapse/simple-crlf.txt
Normal file
@ -0,0 +1,5 @@
|
||||
a;b;c 1
|
||||
a;b;c 1
|
||||
a;b;d 4
|
||||
a;b;c 3
|
||||
a;b 5
|
@ -50,6 +50,60 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`importFromBGFlameGraph with CRLF 1`] = `
|
||||
Object {
|
||||
"frames": Array [
|
||||
Frame {
|
||||
"col": undefined,
|
||||
"file": undefined,
|
||||
"key": "a",
|
||||
"line": undefined,
|
||||
"name": "a",
|
||||
"selfWeight": 0,
|
||||
"totalWeight": 14,
|
||||
},
|
||||
Frame {
|
||||
"col": undefined,
|
||||
"file": undefined,
|
||||
"key": "b",
|
||||
"line": undefined,
|
||||
"name": "b",
|
||||
"selfWeight": 5,
|
||||
"totalWeight": 14,
|
||||
},
|
||||
Frame {
|
||||
"col": undefined,
|
||||
"file": undefined,
|
||||
"key": "c",
|
||||
"line": undefined,
|
||||
"name": "c",
|
||||
"selfWeight": 5,
|
||||
"totalWeight": 5,
|
||||
},
|
||||
Frame {
|
||||
"col": undefined,
|
||||
"file": undefined,
|
||||
"key": "d",
|
||||
"line": undefined,
|
||||
"name": "d",
|
||||
"selfWeight": 4,
|
||||
"totalWeight": 4,
|
||||
},
|
||||
],
|
||||
"name": "simple-crlf.txt",
|
||||
"stacks": Array [
|
||||
"a;b;c 2",
|
||||
"a;b;d 4",
|
||||
"a;b;c 3",
|
||||
"a;b 5",
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`importFromBGFlameGraph with CRLF: indexToView 1`] = `0`;
|
||||
|
||||
exports[`importFromBGFlameGraph with CRLF: profileGroup.name 1`] = `"simple-crlf.txt"`;
|
||||
|
||||
exports[`importFromBGFlameGraph: indexToView 1`] = `0`;
|
||||
|
||||
exports[`importFromBGFlameGraph: profileGroup.name 1`] = `"simple.txt"`;
|
||||
|
@ -3,3 +3,7 @@ import {checkProfileSnapshot} from '../lib/test-utils'
|
||||
test('importFromBGFlameGraph', async () => {
|
||||
await checkProfileSnapshot('./sample/profiles/stackcollapse/simple.txt')
|
||||
})
|
||||
|
||||
test('importFromBGFlameGraph with CRLF', async () => {
|
||||
await checkProfileSnapshot('./sample/profiles/stackcollapse/simple-crlf.txt')
|
||||
})
|
||||
|
@ -103,7 +103,7 @@ async function _importProfileGroup(
|
||||
// If every line ends with a space followed by a number, it's probably
|
||||
// the collapsed stack format.
|
||||
const lineCount = contents.split(/\n/).length
|
||||
if (lineCount >= 1 && lineCount === contents.split(/ \d+\n/).length) {
|
||||
if (lineCount >= 1 && lineCount === contents.split(/ \d+\r?\n/).length) {
|
||||
console.log('Importing as collapsed stack format')
|
||||
return toGroup(importFromBGFlameGraph(contents))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user