def process_task(task: Task) -> None:
    """Extract kernel execution time and workspace from task process outputs

    Parameters
    ----------
    task : Task
        A profiling task
    """
    stdout = task._stdout
    stderr = task._stderr
    single_file_profiler = False

    if len(stderr) > 0:
        # TODO: ugly fix, should remove when finish all profiler refactor
        runtimes = PROF_RUNTIME_PATTERN.findall(stdout)
        if len(runtimes) > 0:
            single_file_profiler = True
        if not single_file_profiler:
            task._failed = True
            return
        _LOGGER.debug(
            "Failed: [{name}][{algo}]\ncmd:\n{cmd}\nstderr:\n{stderr}".format(
                name=task._name,
                algo=task._idx,
                cmd=task._cmd,
                stderr=stderr,
            ),
        )
    task._ret, task._failed = extract_profile_result(
        stdout=stdout,
        return_ops=task._kwargs.get("return_ops", None),
    )
    if not task._failed:
        results = task._ret
        if not isinstance(results, list):
            results = [results]
        for result in results:
            _LOGGER.debug(
                f"Successful: [{task._name}][{task._idx}]: OP: {result.op_config} "
                f"TIME: {result.duration} WS:{result.workspace}",
            )
Extract kernel execution time and workspace from task process outputs

Parameters
----------
task : Task
A profiling task
python/aitemplate/backend/profiler_runner.py