Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 15ec084

Browse files
committed
Allow selective training only with certain cases
1 parent a1bab3d commit 15ec084

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

bin/phpsdk_pgo.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
use SDK\Exception;
77
use SDK\Build\PGO\Controller;
88

9-
$sopt = "itudhs:fr";
10-
$lopt = array("init", "train", "up", "down", "help", "scenario:", "force", "ready");
9+
$sopt = "itudhs:frc:";
10+
$lopt = array("init", "train", "up", "down", "help", "scenario:", "force", "ready", "cases:");
1111

1212
$cmd = NULL;
1313
/* TODO For now we simply check the current php build, this could be extended to take arbitrary binaries. */
1414
$deps_root = NULL;
1515
$php_root = NULL;
1616
$scenario = NULL;
1717
$force = false;
18+
$cases = NULL;
1819

1920
try {
2021
$opt = getopt($sopt, $lopt);
@@ -47,6 +48,10 @@
4748
case "force":
4849
$force = true;
4950
break;
51+
case "c":
52+
case "cases":
53+
$cases = explode(",", $val);
54+
break;
5055
case "h": case "help":
5156
usage(0);
5257
break;
@@ -73,7 +78,7 @@
7378
}
7479
}
7580

76-
$controller = new Controller($cmd, $scenario);
81+
$controller = new Controller($cmd, $scenario, $cases);
7782
$controller->handle($force);
7883

7984
if ("check_init" == $cmd) {
@@ -105,6 +110,7 @@ function usage(int $code = -1)
105110
echo " -d --down Shutdown training environment.", PHP_EOL;
106111
echo " -f --force Force requested operation. Not every option can be forced.", PHP_EOL;
107112
echo " -s --scenario Run training with a specified scenario.", PHP_EOL;
113+
echo " -c --cases Run training with a specified cases only.", PHP_EOL;
108114

109115
/*echo " -p --php-root PHP binary to train.", PHP_EOL;*/
110116

lib/php/libsdk/SDK/Build/PGO/Controller.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ class Controller
1717
protected $cmd;
1818
protected $scenario;
1919
protected $conf;
20+
protected $cases;
2021

21-
public function __construct(string $cmd, ?string $scenario)
22+
public function __construct(string $cmd, ?string $scenario, ?array $cases)
2223
{
2324
$this->cmd = $cmd;
2425

2526
if (NULL == $scenario) {
2627
$scenario = "default";
2728
}
2829
$this->scenario = $scenario;
30+
$this->cases = $cases;
2931
}
3032

3133
protected function vitalizeSrv()
@@ -205,6 +207,10 @@ public function train()
205207
unset($pgo);
206208

207209
foreach (new TrainingCaseIterator($this->conf) as $handler) {
210+
if ($this->cases && !in_array($handler->getName(), $this->cases)) {
211+
continue;
212+
}
213+
208214
echo "\n";
209215
$handler->run();
210216
}

0 commit comments

Comments
 (0)