Skip to content

In the R script exercise 4 :round function behaves strange giving wrong time estimates for plotting #2

@charxydo

Description

@charxydo

Problem

Inside the loop :
for(n in n_cores){
. . . 
time_taken <- round(end_time - start_time, digits = 2)
. . . 
  time_runs <- c(time_runs, time_taken)
}
Calculation of time_taken returns false results for the minute long runs probably an issue with round() function that coerces the diff_time object: end_time - start_time
Visualize the error later 

plot(n_cores, time_runs)
Plot shows only couple seconds timed runs with 2,3 and 4 core usage 

### Proposed fix
Replace line : 
r
time_taken <- round(end_time - start_time, digits = 2)
with :
r
 time_taken <- round(as.numeric(end_time - start_time, units = "secs"), 2)

Fix produces expected behavior : with 2,3 and 4 core usage runs take couple minutes to complete 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions