Skip to content

Commit

Permalink
Create memoryUsage.R
Browse files Browse the repository at this point in the history
  • Loading branch information
Cecilsingh authored Sep 5, 2024
1 parent 0610ed3 commit 09b0d43
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions memoryHandling/memoryUsage.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#The rep() function is used to repeate
#The value to be repeated is the number 1
#1e9 is the scientific notation for one billion

firstHalfMem <- rep(1, 1e9)

secondHalfMem <- rep(1, 1e9)

#additionalMem <- rep(1, 1e8)

#Measures the time taken for a specific block of code to execute, in this case, a for loop
#The tictoc package provides functions to measure time
#tictoc::tic() starts the timer and records the current time which is used to measure the duration of code execution
#The for loop iterates 100 times
#tictoc::toc() stops the timer
#tic() shows how long the code inside tic() and toc() calls took to execute
library(tictoc)

tictoc::tic()

for (i in 1:100){
j=i+1
#gc()
}

tictoc::toc()


#rm(firstHalfMem)

#gc()

0 comments on commit 09b0d43

Please sign in to comment.