Skip to content

Commit e4284e4

Browse files
committed
Add command to stop stress tester
1 parent fe2482c commit e4284e4

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Fast Olympic Coding is an extension to assist with various tasks in competitive
2626
- Delete all testcases: `Ctrl+Alt+D`
2727
- Save all testcases: `Ctrl+Alt+S`
2828
- Run stress test: `Ctrl+Alt+G`
29+
- Stop stress test: `Ctrl+Alt+H`
2930
- Insert file template: `Ctrl+Alt+I`
3031

3132
### 📥 Install within VSCode or at [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=sam20908.vscode-fastolympiccoding)

package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,13 @@
213213
"category": "Fast Olympic Coding"
214214
},
215215
{
216-
"command": "fastolympiccoding.stressTest",
217-
"title": "Run Stress Test",
216+
"command": "fastolympiccoding.startStressTest",
217+
"title": "Start Stress Test",
218+
"category": "Fast Olympic Coding"
219+
},
220+
{
221+
"command": "fastolympiccoding.stopStressTest",
222+
"title": "Stop Stress Test",
218223
"category": "Fast Olympic Coding"
219224
},
220225
{
@@ -265,10 +270,15 @@
265270
"when": "view.fastolympiccoding.judge.visible"
266271
},
267272
{
268-
"command": "fastolympiccoding.stressTest",
273+
"command": "fastolympiccoding.startStressTest",
269274
"key": "ctrl+alt+g",
270275
"when": "view.fastolympiccoding.stress.visible"
271276
},
277+
{
278+
"command": "fastolympiccoding.stopStressTest",
279+
"key": "ctrl+alt+h",
280+
"when": "view.fastolympiccoding.stress.visible"
281+
},
272282
{
273283
"command": "fastolympiccoding.insertFileTemplate",
274284
"key": "ctrl+alt+i"

src/extension.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,18 @@ function registerCommands(context: vscode.ExtensionContext): void {
113113

114114
context.subscriptions.push(
115115
vscode.commands.registerTextEditorCommand(
116-
'fastolympiccoding.stressTest',
116+
'fastolympiccoding.startStressTest',
117117
() => void stressViewProvider.run(),
118118
),
119119
);
120120

121+
context.subscriptions.push(
122+
vscode.commands.registerTextEditorCommand(
123+
'fastolympiccoding.stopStressTest',
124+
() => stressViewProvider.stop(),
125+
),
126+
);
127+
121128
context.subscriptions.push(
122129
vscode.commands.registerTextEditorCommand(
123130
'fastolympiccoding.clearData',

src/views/stress/provider/StressViewProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default class extends BaseViewProvider<ProviderMessage, WebviewMessage> {
4949
void this.run();
5050
break;
5151
case ProviderMessageType.STOP:
52-
this._stop();
52+
this.stop();
5353
break;
5454
case ProviderMessageType.VIEW:
5555
this._view(msg);
@@ -64,7 +64,7 @@ export default class extends BaseViewProvider<ProviderMessage, WebviewMessage> {
6464
}
6565

6666
onDispose() {
67-
this._stop();
67+
this.stop();
6868
}
6969

7070
constructor(
@@ -85,7 +85,7 @@ export default class extends BaseViewProvider<ProviderMessage, WebviewMessage> {
8585
}
8686

8787
loadCurrentFileData() {
88-
this._stop();
88+
this.stop();
8989
for (let id = 0; id < 3; id++) {
9090
this._state[id].data.reset();
9191
this._state[id].status = Status.NA;
@@ -341,7 +341,7 @@ export default class extends BaseViewProvider<ProviderMessage, WebviewMessage> {
341341
this._saveState();
342342
}
343343

344-
private _stop() {
344+
stop() {
345345
this._stopFlag = true;
346346
for (let i = 0; i < 3; i++) {
347347
this._state[i].process.process?.kill('SIGUSR1');

0 commit comments

Comments
 (0)