I had restarted R and R sessions many times at first, still got the same results. But two days later, I re-ran the program, and got very different results. The isoweek() is much faster than strftime() this time, althought still much slower than {clock} package. Don't know what happened. But I'm glad the problem is solved. So I'm using {clock} package for my program.
library(lubridate)
library(dplyr)
library(clock)
system.time({
sim_data |>
mutate(week_base = strftime(dates, format = "%V"))
})
# user system elapsed
# 3.00 0.02 3.04
system.time({
sim_data |>
mutate(week = isoweek(dates))
})
# user system elapsed
# 0.56 0.03 0.60
system.time({
sim_data |>
mutate(isoweek = get_week(as_iso_year_week_day(dates)))
})
# user system elapsed
# 0.05 0.02 0.09