import time


rule all:
    input:
        "test.benchmark_shell.jsonl",
        "test.benchmark_script.jsonl",
        "test.benchmark_run.jsonl",
        "test.benchmark_run_shell.jsonl",


rule bench_shell:
    input:
        "input1.zero",
        "input2.zero",
    benchmark:
        repeat("{name}.benchmark_shell.{ext}", 2)
    params:
        timeout = 4,
    threads: 2
    shell:
        "stress-ng --cpu {threads} --timeout {params.timeout}s"


rule bench_script:
    input:
        "input1.zero",
        "input2.zero",
    benchmark:
        "{name}.benchmark_script.{ext}"
    script:
        "script.py"


rule bench_run:
    input:
        "input1.zero",
        "input2.zero",
    benchmark:
        "{name}.benchmark_run.{ext}"
    params:
        sleep=1,
    run:
        time.sleep(params.sleep)


rule bench_run_shell:
    input:
        "input1.zero",
        "input2.zero",
    benchmark:
        "{name}.benchmark_run_shell.{ext}"
    params:
        sleep=1,
    run:
        shell("sleep {params.sleep}")
