plot_metrics: Plot test-file metrics across versions.

View source: R/plot_metrics.R

plot_metricsR Documentation

Plot test-file metrics across versions.

Description

Given a test-file path, plot the metrics of entire file and individual testthat blocks against the commit message summaries of the specified number of commits in the current git repository. If the parameter save_data is set to true, it also stores the corresponding data-frames in an RData file in a folder 'Rperform_Data' in the current directory.The metrics plotted are in accordance with those specified using the parameter metric.

Usage

plot_metrics(test_path, metric, num_commits = 5, save_data = FALSE,
  save_plots = FALSE, interactive = FALSE)

Arguments

test_path

File-path of the test-file which is to be used for run-time comparisons.

metric

Type of plot(s) desired. This can be set to time, memory, memtime or testMetrics. (See examples below for more details)

num_commits

Number of commits (versions) against which the file is to be tested, with default being 5.

save_data

If set to TRUE, the data frame containing the metrics information is stored in the 'Rperform_Data' directory in the root of the repo. (default set to FALSE)

save_plots

If set to TRUE, the plots generated are stored in the 'Rperform_plots' directory in the root of the repo rather than being printed. (default set to TRUE)

interactive

If set to TRUE, the plots generated are interactive. The resulting plot is rendered in the default browser.

WARNING

Function assumes the current directory to be the root directory of the repository/package being tested.

Examples


## Not run: 
# Set the current directory to the git repository concerned.
setwd("./Path/to/repository")

# Specify the test-file path
t_path <- "Path/to/file"

# Load the library
library(Rperform)

## Example-1

# Pass the parameters and obtain the run-time followed by memory details against 10 commits
plot_metrics(test_path = t_path, metric = "time", n_commits = 10, save_data = F)
plot_metrics(test_path = t_path, metric = "memory", n_commits = 10, save_data = F)

## Example-2

# Obtain both memory and time metrics for each individual testthat block
# inside a file and the file itself. The plots get stored in a directory
# 'Rperform_testMetrics' in the repo's root directory.
plot_metrics(test_path = t_path, metric = "testMetrics", n_commits = 5, save_data = F)

## End(Not run)


analyticalmonk/Rperform documentation built on July 3, 2022, 2:36 a.m.