library(rbenchmark)

# Mean along 1 dim
benchmark(
          "s2dv, 1 core" = {
            data <- array(rnorm(1:60000),
                          dim = c(dat = 1, ftime = 12, member = 6, lon = 20, lat = 50))
            res <- s2dv::Trend(data)
          },
          "s2dv, 2 cores" = {
            data <- array(rnorm(1:60000),
                          dim = c(dat = 1, ftime = 12, member = 6, lon = 20, lat = 50))
            res <- s2dv::Trend(data)
          },

          "s2dverification" = {
             data <- array(rnorm(1:60000),
                           dim = c(dat = 1, ftime = 12, member = 6, lon = 20, lat = 50))
             res <- s2dverification::Trend(data)
          },
          replications = 10,
          columns = c("test", "replications", "elapsed",
                      "relative", "user.self", "sys.self"))

# member = 6, ftime = 12
             test replications elapsed relative user.self sys.self
1    s2dv, 1 core           10 172.298    2.542   170.987    0.928
2   s2dv, 2 cores           10 172.764    2.549   171.435    0.948
3 s2dverification           10  67.790    1.000    67.284    0.356

# member = 6, ftime = 120
             test replications elapsed relative user.self sys.self
1    s2dv, 1 core           10 176.569    2.500   175.687    0.472
2   s2dv, 2 cores           10 178.390    2.526   176.647    1.240
3 s2dverification           10  70.621    1.000    69.844    0.616

