Compare commits

..

3 Commits

Author SHA1 Message Date
Pavel Shevaev 97e948d132 Artefact is considered stale if passed changed files match the spec (without additional stale check)
Publish PHP Package / docker (push) Successful in 3m28s Details
2025-04-29 14:11:51 +03:00
Pavel Shevaev ade0ef5373 Adding --bench option to show basic tasks bench info
Publish PHP Package / docker (push) Successful in 7s Details
2025-04-28 14:38:13 +03:00
Pavel Shevaev 058ab92420 array_splice possible fix
Publish PHP Package / docker (push) Successful in 6s Details
2025-04-28 14:28:29 +03:00
3 changed files with 32 additions and 14 deletions

View File

@ -89,11 +89,19 @@ class TaskmanArtefact
{
if(!isset($this->sources_affected[$idx]))
{
$sources = $this->task->getFileChanges() != null ?
//tries to match changed files with sources spec
$this->getChangedSources($idx) :
$this->getSources($idx);
$this->sources_affected[$idx] = is_stale($this->getPath(), $sources);
//NOTE: more conservative implementation which always checks for staleness
//$sources = $this->task->getFileChanges() != null ?
// //tries to match changed files with sources spec
// $this->getChangedSources($idx) :
// $this->getSources($idx);
//$this->sources_affected[$idx] = is_stale($this->getPath(), $sources);
//NOTE: if there any file changes we simply check if there are any changed sources,
// and if yes then we mark the artefact as affected
if($this->task->getFileChanges() != null)
$this->sources_affected[$idx] = count($this->getChangedSources($idx)) > 0;
else
$this->sources_affected[$idx] = is_stale($this->getPath(), $this->getSources($idx));
}
return $this->sources_affected[$idx];

View File

@ -171,6 +171,7 @@ function _process_argv(array &$argv)
global $TASKMAN_BATCH;
global $TASKMAN_NO_DEPS;
global $TASKMAN_FILE_CHANGES;
global $TASKMAN_SHOW_BENCH;
$filtered = array();
$process_defs = false;
@ -185,10 +186,6 @@ function _process_argv(array &$argv)
$filtered[] = $argv[$j];
break;
}
else if($v == '-D')
{
$process_defs = true;
}
else if($v == '-V')
{
$TASKMAN_LOG_LEVEL = 2;
@ -213,6 +210,10 @@ function _process_argv(array &$argv)
{
$TASKMAN_NO_DEPS = true;
}
else if($v == '--bench')
{
$TASKMAN_SHOW_BENCH = true;
}
else if($v == '-c')
{
if(!isset($argv[$i+1]))
@ -229,6 +230,10 @@ function _process_argv(array &$argv)
++$i;
}
else if($v == '-D')
{
$process_defs = true;
}
else if($process_defs)
{
$eq_pos = strpos($v, '=');
@ -291,8 +296,10 @@ function _extract_lines_from_file(string $file_path) : array
function _show_bench(array $tasks, int $limit = 5)
{
$times = array();
if(!$tasks)
return;
$times = array();
foreach($tasks as $name => $task)
{
if($task->hasRun())
@ -300,17 +307,18 @@ function _show_bench(array $tasks, int $limit = 5)
}
uasort($times, fn($a, $b) => $b <=> $a);
array_splice($times, $limit);
if(count($times) > $limit)
array_splice($times, $limit);
if(!$times)
return;
\taskman\log(2, "Top ".count($times)." time consuming tasks:\n");
\taskman\log(1, "Top ".count($times)." time consuming tasks:\n");
$n = 0;
foreach($times as $name => $time)
{
++$n;
\taskman\log(2, "$n) Task '$name': $time sec\n");
\taskman\log(1, "$n) Task '$name': $time sec\n");
}
}

View File

@ -16,6 +16,7 @@ $GLOBALS['TASKMAN_LOGGER'] = '\taskman\internal\_default_logger';
$GLOBALS['TASKMAN_ERROR_HANDLER'] = null;
$GLOBALS['TASKMAN_START_TIME'] = 0;
$GLOBALS['TASKMAN_FILES_CHANGES'] = null;
$GLOBALS['TASKMAN_SHOW_BENCH'] = false;
include_once(__DIR__ . '/internal.inc.php');
include_once(__DIR__ . '/util.inc.php');
@ -525,7 +526,8 @@ function main(
else if($default_task)
run($default_task, $argv);
internal\_show_bench($task_objs);
if($GLOBALS['TASKMAN_SHOW_BENCH'])
internal\_show_bench($task_objs);
log(0, "***** All done (".round(microtime(true)-$GLOBALS['TASKMAN_START_TIME'],2)." sec.) *****\n");
}