RJoules - An Energy Measurement Tool for R


Tool Description

RJoules, a tool designed to measure the energy consumption of code snippets written in R. It is a wrapper interface developed on top of Intel RAPL, enabling the logging of energy traces directly from the operating system

Installation

Requirements

  • Intel processors from the Celeron, Pentium, Core i3, i7, i9, and Xeon series, featuring the Sandy Bridge or newer architecture.
  • Linux distribution Debian based operating system. We have tested on Ubuntu 20.04 and 22.04 Versions(recommended).
  • Have R installed in your system.

If you are using Ubuntu 22.04 please run the below commands to install R.
  • wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo gpg --dearmor -o /usr/share/keyrings/r-project.gpg
  • echo "deb [signed-by=/usr/share/keyrings/r-project.gpg] https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/" | sudo tee -a /etc/apt/sources.list.d/r-project.list
  • sudo apt update
  • sudo apt install --no-install-recommends r-base
  • sudo -i R

From Github

STEP1: Clone or download this github repository:

git clone https://github.com/rishalab/RJoules.git


STEP2: Navigate into the RJoules_main directory, copy the path of energy_measurement.R

cd RJoules/RJoules_main

pwd

For testing we have provided few test files here. Take any of the test file and update the PATH following STEP3 and run the below commands

cd RJoules/Test_files R<TESTFILENAME.R

STEP3: If you want to measure energy in your R script. Create a R script example. R and Import/source RJoules

source("PATH/energy_measurement.R")

STEP4: Write the code for which energy measurements need to be done inside a function block as below example in example.R.

test_foo<-function(){
print("This is my foo function..")
df <- data.frame("Age" = c(12, 21, 15, 5, 25), "Name" = c("Johnny", "Glen", "Alfie","Jack", "Finch"))
newdf <- df[order(df$Age), ]
print(newdf)
}

STEP5: Call measure_energy function defined in RJoules with test function name as parameter

measure_energy(test_foo)()

STEP6: Run example.R in console to get Energy measurements

R<example.R --no-save>

STEP7: Check the output in output.csv file

vi output.csv


Usage

Measuring energy consumption due to R code snippets.

Approach diagram

RJoules uses intel-RAPL interface to measure energy consumption. The tool is developed for getting package and dram domain energy consumption due to R code snippet. The internal workflow is described in the below figure.

elegant icons
  • Code snippet creenshot


    • screenshot

    Goal

    Helping developers and practitioners to develope energy efficient code in R language.

    Results

    The evaluation experiments have been done on 3 systems of different configurations considering 4 machine learning algorithms. Results

    Demo Video

    The output file name has been updated as RJoules_output.csv

    Contributors

    Rajrupa chattaraj, Sridhar Chimalakonda