We used the rbenchmark package to benchmark the packages, considering the number of replications, elapsed time, relative performance, user CPU time, and system CPU time. In this blog post, we compared the performance of three R packages, writexl, openxlsx, and xlsx, for writing Excel files. The difference in performance between the three packages is not significant, but writexl is consistently faster than the other two packages. The results of the benchmark show that writexl is the fastest package for writing to Excel, followed by openxlsx and xlsx. Test replications elapsed relative lf sys.selfģ xlsx 5 0.101 2.941176 0.078 0.023 Interpretation of the Results To make the results more readable, we can use the arrange() function from the dplyr package to sort the results by the “relative” column in ascending order. We specify “test” for the test name, “replications” for the number of replications, “elapsed” for the total time taken, “relative” for the relative performance compared to the fastest test, “lf” for the CPU time used in user code, and “sys.self” for the CPU time used in system code. The columns parameter defines the columns to include in the benchmarking results. In our case, we set it to n, which we defined earlier as 5. The replications parameter specifies the number of times each test should be repeated. For example, in the “writexl” test, we use the write_xlsx() function from the writexl package to write the “flights” dataset to a temporary Excel file. We provide the code to execute for each test. In the code snippet above, we define three tests, each representing one package. Xlsx::write.xlsx(flights, paste0(tempfile(),".xlsx")) Openxlsx::write.xlsx(flights, tempfile())
0 Comments
Leave a Reply. |