Browse Source

Adds debug log timings for parsers

main
Eric Amodio 5 years ago
parent
commit
8551edcceb
10 changed files with 26 additions and 6 deletions
  1. +2
    -1
      src/git/parsers/blameParser.ts
  2. +1
    -1
      src/git/parsers/branchParser.ts
  3. +5
    -1
      src/git/parsers/diffParser.ts
  4. +4
    -1
      src/git/parsers/logParser.ts
  5. +2
    -0
      src/git/parsers/remoteParser.ts
  6. +2
    -0
      src/git/parsers/shortlogParser.ts
  7. +2
    -1
      src/git/parsers/stashParser.ts
  8. +4
    -1
      src/git/parsers/statusParser.ts
  9. +2
    -0
      src/git/parsers/tagParser.ts
  10. +2
    -0
      src/git/parsers/treeParser.ts

+ 2
- 1
src/git/parsers/blameParser.ts View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import * as paths from 'path'; import * as paths from 'path';
import { Strings } from '../../system';
import { Git, GitAuthor, GitBlame, GitBlameCommit, GitCommitLine } from '../git'; import { Git, GitAuthor, GitBlame, GitBlameCommit, GitCommitLine } from '../git';
import { debug, Strings } from '../../system';
const emptyStr = ''; const emptyStr = '';
const slash = '/'; const slash = '/';
@ -30,6 +30,7 @@ interface BlameEntry {
} }
export class GitBlameParser { export class GitBlameParser {
@debug({ args: false, singleLine: true })
static parse( static parse(
data: string, data: string,
repoPath: string | undefined, repoPath: string | undefined,

+ 1
- 1
src/git/parsers/branchParser.ts View File

@ -17,7 +17,7 @@ export class GitBranchParser {
`${lb}r${rb}%(objectname)` // ref `${lb}r${rb}%(objectname)` // ref
].join(''); ].join('');
@debug({ args: false })
@debug({ args: false, singleLine: true })
static parse(data: string, repoPath: string): GitBranch[] { static parse(data: string, repoPath: string): GitBranch[] {
const branches: GitBranch[] = []; const branches: GitBranch[] = [];

+ 5
- 1
src/git/parsers/diffParser.ts View File

@ -1,12 +1,13 @@
'use strict'; 'use strict';
import { Strings } from '../../system';
import { GitDiff, GitDiffHunk, GitDiffHunkLine, GitDiffLine, GitDiffShortStat, GitFile, GitFileStatus } from '../git'; import { GitDiff, GitDiffHunk, GitDiffHunkLine, GitDiffLine, GitDiffShortStat, GitFile, GitFileStatus } from '../git';
import { debug, Strings } from '../../system';
const nameStatusDiffRegex = /^(.*?)\t(.*?)(?:\t(.*?))?$/gm; const nameStatusDiffRegex = /^(.*?)\t(.*?)(?:\t(.*?))?$/gm;
const shortStatDiffRegex = /^\s*(\d+)\sfiles? changed(?:,\s+(\d+)\s+insertions?\(\+\))?(?:,\s+(\d+)\s+deletions?\(-\))?/; const shortStatDiffRegex = /^\s*(\d+)\sfiles? changed(?:,\s+(\d+)\s+insertions?\(\+\))?(?:,\s+(\d+)\s+deletions?\(-\))?/;
const unifiedDiffRegex = /^@@ -([\d]+)(?:,([\d]+))? \+([\d]+)(?:,([\d]+))? @@(?:.*?)\n([\s\S]*?)(?=^@@)/gm; const unifiedDiffRegex = /^@@ -([\d]+)(?:,([\d]+))? \+([\d]+)(?:,([\d]+))? @@(?:.*?)\n([\s\S]*?)(?=^@@)/gm;
export class GitDiffParser { export class GitDiffParser {
@debug({ args: false, singleLine: true })
static parse(data: string, debug: boolean = false): GitDiff | undefined { static parse(data: string, debug: boolean = false): GitDiff | undefined {
if (!data) return undefined; if (!data) return undefined;
@ -59,6 +60,7 @@ export class GitDiffParser {
return diff; return diff;
} }
@debug({ args: false, singleLine: true })
static parseHunk(hunk: GitDiffHunk): GitDiffHunkLine[] { static parseHunk(hunk: GitDiffHunk): GitDiffHunkLine[] {
const currentLines: (GitDiffLine | undefined)[] = []; const currentLines: (GitDiffLine | undefined)[] = [];
const previousLines: (GitDiffLine | undefined)[] = []; const previousLines: (GitDiffLine | undefined)[] = [];
@ -122,6 +124,7 @@ export class GitDiffParser {
return hunkLines; return hunkLines;
} }
@debug({ args: false, singleLine: true })
static parseNameStatus(data: string, repoPath: string): GitFile[] | undefined { static parseNameStatus(data: string, repoPath: string): GitFile[] | undefined {
if (!data) return undefined; if (!data) return undefined;
@ -156,6 +159,7 @@ export class GitDiffParser {
return files; return files;
} }
@debug({ args: false, singleLine: true })
static parseShortStat(data: string): GitDiffShortStat | undefined { static parseShortStat(data: string): GitDiffShortStat | undefined {
if (!data) return undefined; if (!data) return undefined;

+ 4
- 1
src/git/parsers/logParser.ts View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
import * as paths from 'path'; import * as paths from 'path';
import { Range } from 'vscode'; import { Range } from 'vscode';
import { Arrays, Strings } from '../../system';
import { Git, GitAuthor, GitCommitType, GitFile, GitFileStatus, GitLog, GitLogCommit } from '../git'; import { Git, GitAuthor, GitCommitType, GitFile, GitFileStatus, GitLog, GitLogCommit } from '../git';
import { Arrays, debug, Strings } from '../../system';
const emptyEntry: LogEntry = {}; const emptyEntry: LogEntry = {};
const emptyStr = ''; const emptyStr = '';
@ -54,6 +54,7 @@ export class GitLogParser {
static simpleFormat = `${lb}r${rb}${sp}%H`; static simpleFormat = `${lb}r${rb}${sp}%H`;
@debug({ args: false })
static parse( static parse(
data: string, data: string,
type: GitCommitType, type: GitCommitType,
@ -393,6 +394,7 @@ export class GitLogParser {
} }
} }
@debug({ args: false })
static parseSimple( static parseSimple(
data: string, data: string,
skip: number skip: number
@ -418,6 +420,7 @@ export class GitLogParser {
return [ref, file, status]; return [ref, file, status];
} }
@debug({ args: false })
static parseSimpleRenamed( static parseSimpleRenamed(
data: string, data: string,
originalFileName: string originalFileName: string

+ 2
- 0
src/git/parsers/remoteParser.ts View File

@ -2,6 +2,7 @@
import { GitRemoteType } from '../models/remote'; import { GitRemoteType } from '../models/remote';
import { RemoteProvider } from '../remotes/factory'; import { RemoteProvider } from '../remotes/factory';
import { GitRemote } from '../git'; import { GitRemote } from '../git';
import { debug } from '../../system';
const emptyStr = ''; const emptyStr = '';
@ -47,6 +48,7 @@ user:password@host.xz:/path/to/repo.git/
*/ */
export class GitRemoteParser { export class GitRemoteParser {
@debug({ args: false, singleLine: true })
static parse( static parse(
data: string, data: string,
repoPath: string, repoPath: string,

+ 2
- 0
src/git/parsers/shortlogParser.ts View File

@ -1,9 +1,11 @@
'use strict'; 'use strict';
import { GitContributor, GitShortLog } from '../git'; import { GitContributor, GitShortLog } from '../git';
import { debug } from '../../system';
const shortlogRegex = /^(.*?)\t(.*?) <(.*?)>$/gm; const shortlogRegex = /^(.*?)\t(.*?) <(.*?)>$/gm;
export class GitShortLogParser { export class GitShortLogParser {
@debug({ args: false, singleLine: true })
static parse(data: string, repoPath: string): GitShortLog | undefined { static parse(data: string, repoPath: string): GitShortLog | undefined {
if (!data) return undefined; if (!data) return undefined;

+ 2
- 1
src/git/parsers/stashParser.ts View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { Arrays, Strings } from '../../system';
import { GitCommitType, GitFile, GitFileStatus, GitLogParser, GitStash, GitStashCommit } from '../git'; import { GitCommitType, GitFile, GitFileStatus, GitLogParser, GitStash, GitStashCommit } from '../git';
import { Arrays, debug, Strings } from '../../system';
// import { Logger } from './logger'; // import { Logger } from './logger';
// Using %x00 codes because some shells seem to try to expand things if not // Using %x00 codes because some shells seem to try to expand things if not
@ -35,6 +35,7 @@ export class GitStashParser {
`${lb}f${rb}` `${lb}f${rb}`
].join('%n'); ].join('%n');
@debug({ args: false, singleLine: true })
static parse(data: string, repoPath: string): GitStash | undefined { static parse(data: string, repoPath: string): GitStash | undefined {
if (!data) return undefined; if (!data) return undefined;

+ 4
- 1
src/git/parsers/statusParser.ts View File

@ -1,5 +1,5 @@
'use strict'; 'use strict';
import { Strings } from '../../system';
import { debug, Strings } from '../../system';
import { GitFileStatus, GitStatus, GitStatusFile } from '../git'; import { GitFileStatus, GitStatus, GitStatusFile } from '../git';
const emptyStr = ''; const emptyStr = '';
@ -8,6 +8,7 @@ const aheadStatusV1Regex = /(?:ahead ([0-9]+))/;
const behindStatusV1Regex = /(?:behind ([0-9]+))/; const behindStatusV1Regex = /(?:behind ([0-9]+))/;
export class GitStatusParser { export class GitStatusParser {
@debug({ args: false, singleLine: true })
static parse(data: string, repoPath: string, porcelainVersion: number): GitStatus | undefined { static parse(data: string, repoPath: string, porcelainVersion: number): GitStatus | undefined {
if (!data) return undefined; if (!data) return undefined;
@ -19,6 +20,7 @@ export class GitStatusParser {
return this.parseV2(lines, repoPath); return this.parseV2(lines, repoPath);
} }
@debug({ args: false, singleLine: true })
private static parseV1(lines: string[], repoPath: string): GitStatus { private static parseV1(lines: string[], repoPath: string): GitStatus {
let branch: string | undefined; let branch: string | undefined;
const files = []; const files = [];
@ -61,6 +63,7 @@ export class GitStatusParser {
return new GitStatus(Strings.normalizePath(repoPath), branch || emptyStr, emptyStr, files, state, upstream); return new GitStatus(Strings.normalizePath(repoPath), branch || emptyStr, emptyStr, files, state, upstream);
} }
@debug({ args: false, singleLine: true })
private static parseV2(lines: string[], repoPath: string): GitStatus { private static parseV2(lines: string[], repoPath: string): GitStatus {
let branch: string | undefined; let branch: string | undefined;
const files = []; const files = [];

+ 2
- 0
src/git/parsers/tagParser.ts View File

@ -1,10 +1,12 @@
'use strict'; 'use strict';
import { GitTag } from '../git'; import { GitTag } from '../git';
import { debug } from '../../system';
const tagWithRefRegex = /([0-9,a-f]+)\srefs\/tags\/(.*)/gm; const tagWithRefRegex = /([0-9,a-f]+)\srefs\/tags\/(.*)/gm;
const tagWithAnnotationRegex = /^(.+?)(?:$|(?:\s+)(.*)$)/gm; const tagWithAnnotationRegex = /^(.+?)(?:$|(?:\s+)(.*)$)/gm;
export class GitTagParser { export class GitTagParser {
@debug({ args: false, singleLine: true })
static parse(data: string, repoPath: string): GitTag[] | undefined { static parse(data: string, repoPath: string): GitTag[] | undefined {
if (!data) return undefined; if (!data) return undefined;

+ 2
- 0
src/git/parsers/treeParser.ts View File

@ -1,10 +1,12 @@
'use strict'; 'use strict';
import { GitTree } from '../git'; import { GitTree } from '../git';
import { debug } from '../../system';
const emptyStr = ''; const emptyStr = '';
const treeRegex = /(?:.+?)\s+(.+?)\s+(.+?)\s+(.+?)\s+(.+)/gm; const treeRegex = /(?:.+?)\s+(.+?)\s+(.+?)\s+(.+?)\s+(.+)/gm;
export class GitTreeParser { export class GitTreeParser {
@debug({ args: false, singleLine: true })
static parse(data: string | undefined): GitTree[] | undefined { static parse(data: string | undefined): GitTree[] | undefined {
if (!data) return undefined; if (!data) return undefined;

Loading…
Cancel
Save