pub fn bench(
repo_url: &str,
build_command: &str,
source_dir: &str,
build_dir: &str,
repo_exists: bool,
) -> impl Iterator<Item = String>Expand description
Runs the benchmark.
This method takes in the repository URL, build command, source directory, build directory, and a flag indicating whether the repository already exists.
It creates a channel for communication between threads and spawns a new thread to perform the benchmarking.
If the repository does not exist, it clones the repository using git clone command.
It then checks if the build directory exists and removes it if it does.
If the system is plugged in, it waits for the system to be unplugged before starting the benchmarking.
It creates a log file with a timestamp and starts an infinite loop.
In each iteration of the loop, it copies the source directory to the build directory, changes the current directory to the build directory, executes the build command, changes the current directory back, removes the build directory, and increments the score in the log file.
The output of each step is sent through the channel to be consumed by the main thread.
The method returns an iterator over the output lines received from the channel.