Skip to content

Commit 0fdf856

Browse files
committed
Adds performance logging
1 parent aacf7cc commit 0fdf856

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/annotations/gutterBlameAnnotationProvider.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Annotations, endOfLineIndex } from './annotations';
66
import { BlameAnnotationProviderBase } from './blameAnnotationProvider';
77
import { GlyphChars } from '../constants';
88
import { GitBlameCommit, ICommitFormatOptions } from '../gitService';
9+
import { Logger } from '../logger';
910

1011
export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
1112

@@ -15,7 +16,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
1516
const blame = await this.getBlame(true);
1617
if (blame === undefined) return false;
1718

18-
// console.time('Computing blame annotations...');
19+
const start = process.hrtime();
1920

2021
const cfg = this._config.annotations.file.gutter;
2122

@@ -114,7 +115,8 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
114115
this.editor.setDecorations(this.decoration!, decorations);
115116
}
116117

117-
// console.timeEnd('Computing blame annotations...');
118+
const duration = process.hrtime(start);
119+
Logger.log(`${(duration[0] * 1000) + Math.floor(duration[1] / 1000000)} ms to compute gutter blame annotations`);
118120

119121
this.selection(shaOrLine, blame);
120122
return true;

src/annotations/hoverBlameAnnotationProvider.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { FileAnnotationType } from './annotationController';
44
import { Annotations, endOfLineIndex } from './annotations';
55
import { BlameAnnotationProviderBase } from './blameAnnotationProvider';
66
import { GitBlameCommit } from '../gitService';
7+
import { Logger } from '../logger';
78

89
export class HoverBlameAnnotationProvider extends BlameAnnotationProviderBase {
910

@@ -13,7 +14,7 @@ export class HoverBlameAnnotationProvider extends BlameAnnotationProviderBase {
1314
const blame = await this.getBlame(this._config.annotations.file.hover.heatmap.enabled);
1415
if (blame === undefined) return false;
1516

16-
// console.time('Computing blame annotations...');
17+
const start = process.hrtime();
1718

1819
const cfg = this._config.annotations.file.hover;
1920

@@ -55,7 +56,8 @@ export class HoverBlameAnnotationProvider extends BlameAnnotationProviderBase {
5556
this.editor.setDecorations(this.decoration!, decorations);
5657
}
5758

58-
// console.timeEnd('Computing blame annotations...');
59+
const duration = process.hrtime(start);
60+
Logger.log(`${(duration[0] * 1000) + Math.floor(duration[1] / 1000000)} ms to compute hover blame annotations`);
5961

6062
this.selection(shaOrLine, blame);
6163
return true;

src/annotations/recentChangesAnnotationProvider.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Annotations, endOfLineIndex } from './annotations';
44
import { FileAnnotationType } from './annotationController';
55
import { AnnotationProviderBase } from './annotationProvider';
66
import { GitService, GitUri } from '../gitService';
7+
import { Logger } from '../logger';
78

89
export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
910

@@ -20,6 +21,8 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
2021
const diff = await this.git.getDiffForFile(this.uri, commit.previousSha);
2122
if (diff === undefined) return false;
2223

24+
const start = process.hrtime();
25+
2326
const cfg = this._config.annotations.file.recentChanges;
2427
const dateFormat = this._config.defaultDateFormat;
2528

@@ -62,6 +65,9 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
6265

6366
this.editor.setDecorations(this.highlightDecoration!, decorators);
6467

68+
const duration = process.hrtime(start);
69+
Logger.log(`${(duration[0] * 1000) + Math.floor(duration[1] / 1000000)} ms to compute recent changes annotations`);
70+
6571
return true;
6672
}
6773

0 commit comments

Comments
 (0)