chatStreamStats.ts ×6

Frontier kind: Joint frontier

unlabeled · c_f5f8b2e94709

11 tests · 10532 LOC · 53 files · introduces 2 tests · 73 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges73 lines · 1 files
Tests
2 tests

Contains — complete concept membership

All code (extent)
1648 ranges10532 lines · 53 files · Browse complete extent
All tests (intent)
11 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

2 tests introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 73 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/model/chatStreamStats.ts 73 introduced LOC · 6 ranges

Open complete file

52
53 constructor(
54 > @ILogService private readonly logService: ILogService chatStreamStats.ts
55 > ) {
56 > const start = Date.now();
57 > this._data = {
58 > totalTime: 0,
59 > lastUpdateTime: start,
60 > impliedWordLoadRate: 0,
61 > lastWordCount: 0,
62 > firstMarkdownTime: undefined,
63 > bootstrapActive: true,
64 > wordCountAtBootstrapExit: undefined,
65 > updatesWithNewWords: 0
66 > };
67 > this._publicData = { impliedWordLoadRate: 0, lastWordCount: 0 };
68 > }
69
70 get data(): IChatStreamStats {
77
78 update(totals: IChatStreamUpdate): IChatStreamStats | undefined {
79 > const { totalWordCount: wordCount } = totals; chatStreamStats.ts
80 > if (wordCount === this._data.lastWordCount) {
81 this.trace('Update- no new words');
82 return undefined;
83 }
85 > const now = Date.now();
86 > const newWords = wordCount - this._data.lastWordCount;
87 > const hadNoWordsBeforeUpdate = this._data.lastWordCount === 0;
88 > let firstMarkdownTime = this._data.firstMarkdownTime;
89 > let wordCountAtBootstrapExit = this._data.wordCountAtBootstrapExit;
90 > if (typeof firstMarkdownTime !== 'number' && wordCount > 0) {
91 > firstMarkdownTime = now;
92 > }
93 > const updatesWithNewWords = this._data.updatesWithNewWords + 1;
94 >
95 > if (hadNoWordsBeforeUpdate) {
96 > this._data.lastUpdateTime = now;
97 > }
98 >
99 > const intervalCap = newWords > WORDS_FOR_LARGE_CHUNK ? LARGE_UPDATE_MAX_INTERVAL_TIME : MAX_INTERVAL_TIME;
100 > const timeDiff = Math.min(now - this._data.lastUpdateTime, intervalCap);
101 > let totalTime = this._data.totalTime + timeDiff;
102 > const minBootstrapTotalTime = hadNoWordsBeforeUpdate && wordCount > WORDS_FOR_LARGE_CHUNK ? LARGE_BOOTSTRAP_MIN_TOTAL_TIME : MIN_BOOTSTRAP_TOTAL_TIME;
103 >
104 > let bootstrapActive = this._data.bootstrapActive;
105 > if (bootstrapActive) {
106 > const stableStartTime = firstMarkdownTime;
107 > const hasStableData = typeof stableStartTime === 'number'
108 > && updatesWithNewWords >= MIN_UPDATES_FOR_STABLE_RATE
109 && wordCount >= WORDS_FOR_LARGE_CHUNK;
110 > if (hasStableData) { chatStreamStats.ts
111 bootstrapActive = false;
112 totalTime = Math.max(now - stableStartTime, timeDiff);
113 wordCountAtBootstrapExit = this._data.lastWordCount;
114 this.trace('Has stable data');
115 > } else { chatStreamStats.ts
116 > totalTime = Math.max(totalTime, minBootstrapTotalTime);
117 > }
118 > }
119 >
120 > const wordsSinceBootstrap = typeof wordCountAtBootstrapExit === 'number' ? Math.max(wordCount - wordCountAtBootstrapExit, 0) : wordCount;
121 > const effectiveTime = totalTime;
122 > const effectiveWordCount = bootstrapActive ? wordCount : wordsSinceBootstrap;
123 > const impliedWordLoadRate = effectiveTime > 0 ? effectiveWordCount / (effectiveTime / 1000) : 0;
124 > this._data = {
125 > totalTime,
126 > lastUpdateTime: now,
127 > impliedWordLoadRate,
128 > lastWordCount: wordCount,
129 > firstMarkdownTime,
130 > bootstrapActive,
131 > wordCountAtBootstrapExit,
132 > updatesWithNewWords
133 > };
134 > this._publicData = {
135 > impliedWordLoadRate,
136 > lastWordCount: wordCount
137 > };
138 >
139 > const traceWords = bootstrapActive ? wordCount : wordsSinceBootstrap;
140 > this.trace(`Update- got ${traceWords} words over last ${totalTime}ms = ${impliedWordLoadRate} words/s`);
141 > return this._data;
142 > }
143
144 private trace(message: string): void {
145 > this.logService.trace(`ChatStreamStatsTracker#update: ${message}`); chatStreamStats.ts
146 > }
147 }