library(rbenchmark)

source("/esarchive/scratch/nperez/git/Flor/s2dv/Reorder.R")
data <- array(rnorm(1:60000),
              dim = c(dat = 1, sdate = 30, time = 12, member = 2, lon = 20, lat = 50))
attributes(data)$time <- 1:12
attributes(data)$dataset <- 'erainterim'
attributes(data)$units <- 'mm'
attributes(data)$prec <- list(units = 'mm', region = 'Europe')

order <- c('lat', 'lon', 'member', 'dat', 'sdate', 'time')

# Mean along 1 dim
benchmark("s2dv, old" = {
            res <- s2dv::Reorder(data, order)
          },

          "s2dv, new" = {
             res <- Reorder(data, order)
          },

          replications = 10,
          columns = c("test", "replications", "elapsed",
                      "relative", "user.self", "sys.self"))

