Benchmarking Results

Computational Resources

All benchmarks were performed on the same machine to ensure consistent comparisons.

  • CPU: Apple M4
  • Number of Cores: 10
  • Memory: 16GB RAM
  • Operating System: macOS Sequoia 15.6
  • Julia Version: 1.10.10
  • R Version: 4.4.2

Benchmarking Methods

To assess the efficiency of MetaCommunityMetrics compared to equivalent R implementations, we benchmark our functions against their R counterparts, focusing on execution time and memory usage. The following tables summarize the benchmark results based on 100 samples each.

We tested using datasets of three sizes:

  • Large (53,352 observations)
  • Medium (26,676 observations, 50% of the size of the large dataset)
  • Small (5,325 observations, 10% of the size of the large dataset)

The large dataset is the sample data included with MetaCommunityMetrics, accessible via load_sample_data(). The small and medium datasets can be accessed here.

Each function was benchmarked using 100 samples in both BenchmarkTools.jl in Julia and bench::mark() in R to ensure robust statistical sampling. For memory usage comparisons:

  • In Julia, we report the memory estimate from BenchmarkTools.jl, which measures bytes allocated for a given expression per sample.

  • In R, we report the mem_alloc metric from bench::mark(), which tracks R heap allocation per sample.

According to documentation, the Julia metric measures total memory allocation during execution, while the R metric specifically tracks heap allocations within the R runtime, excluding "memory allocated outside the R heap, e.g., by malloc() or new directly." Due to differences in language implementation and measurement methodology, direct numerical comparisons between languages should be interpreted with caution.

Speedup Summary

Below is a plot showing the speedup of all benchmarked functions across the three datasets (small, medium and large). Speedup is calculated as the R median execution time divided by the Julia median execution time.Median speedup and its confidence interval of each comparison is shown. The grey dashed line shows where speedup equals to 1, that is both R and Julia's implementations require the same amount of time. The calcualation of beta diversity has two variants: quant = true (abundance data is used) and quant = false(occurence data is used). Speedup Plot

Benchmarking Results in Details

All times are in millisecond (ms), and memory is in mebibytes (MiB). All values are rounded up to 4 decimal places.

Median Execution Time and Speedup Values

Bold text indicates the test cases with maximum and minimum speedup values. 95% confidence interval of the speedup is reported.

Test CaseData SizeJuliaRSpeedupLower CIUpper CI
Beta Diversity (Abundance, quant=true)Large0.13532.417417.862716.149919.5014
Beta Diversity (Abundance, quant=true)Medium0.07811.365517.487916.408518.3717
Beta Diversity (Abundance, quant=true)Small0.04071.152528.312127.275130.5852
Beta Diversity (Abundance, quant=false)Large0.01690.209612.422711.700113.475
Beta Diversity (Abundance, quant=false)Medium0.00910.275630.268127.628932.9273
Beta Diversity (Abundance, quant=false)Small0.00630.321950.999147.795854.1693
Beta Diversity (Presence, quant=false)Large0.01320.210115.92913.048617.7571
Beta Diversity (Presence, quant=false)Medium0.01120.30927.4725.37329.6856
Beta Diversity (Presence, quant=false)Small0.00570.3358.233555.212665.2326
Spatial Beta Diversity (Abundance, quant=true)Large2.11479.2674.38214.3064.4893
Spatial Beta Diversity (Abundance, quant=true)Medium1.98959.20434.62634.4714.7898
Spatial Beta Diversity (Abundance, quant=true)Small1.11958.84487.90077.76958.0108
Spatial Beta Diversity (Abundance, quant=false)Large1.88226.97153.70393.64673.7513
Spatial Beta Diversity (Abundance, quant=false)Medium1.66947.16754.29344.20024.399
Spatial Beta Diversity (Abundance, quant=false)Small0.96956.74696.95936.81017.073
Spatial Beta Diversity (Presence, quant=false)Large1.90226.96383.66083.61863.73
Spatial Beta Diversity (Presence, quant=false)Medium1.67167.21824.31834.17224.4475
Spatial Beta Diversity (Presence, quant=false)Small0.96696.69726.92626.84517.0289
Temporal Beta Diversity (Abundance, quant=true)Large5.865253.30169.08788.78759.2049
Temporal Beta Diversity (Abundance, quant=true)Medium5.21554.320810.416210.031110.6263
Temporal Beta Diversity (Abundance, quant=true)Small4.551552.534211.542211.29411.7076
Temporal Beta Diversity (Abundance, quant=false)Large2.66899.7693.66033.61543.7156
Temporal Beta Diversity (Abundance, quant=false)Medium2.25729.6724.2854.15344.3805
Temporal Beta Diversity (Abundance, quant=false)Small1.57229.01865.73645.55215.9203
Temporal Beta Diversity (Presence, quant=false)Large2.74229.38993.42423.35933.4753
Temporal Beta Diversity (Presence, quant=false)Medium2.31779.62864.15434.04584.3004
Temporal Beta Diversity (Presence, quant=false)Small1.49529.02066.03285.84246.135
Dispersal-niche continuum indexLarge483.22112894.323226.684126.470126.923
Dispersal-niche continuum indexMedium391.891312608.520832.173532.028732.3104
Dispersal-niche continuum indexSmall102.06533376.087933.077732.815533.4182
Occupied Patches ProportionLarge0.68248.589312.586612.08713.1502
Occupied Patches ProportionMedium0.59138.350614.122213.576114.9307
Occupied Patches ProportionSmall0.42097.908618.7916.367520.2831
Variability MetricsLarge13.4022103.5967.72987.59929.6017
Variability MetricsMedium7.872452.27726.64056.59776.7956
Variability MetricsSmall2.832914.07894.96984.93944.9936
Hypervolume EstimationLarge0.00420.03077.36467.11587.5291
Hypervolume EstimationMedium0.00350.02647.45467.33287.544
Hypervolume EstimationSmall0.00340.02667.88417.70327.9327
Hypervolume DissimilarityLarge0.00870.139516.096815.778316.5356
Hypervolume DissimilarityMedium0.00820.110913.575513.481813.665
Hypervolume DissimilaritySmall0.0080.112513.991313.909714.1604

Memory Usage

Benchmarked using Large Dataset

Bold text indicates the test case with the biggest memory usage difference between Julia and R.

Test CaseJuliaR
Beta Diversity (Abundance, quant=true)0.43410.3757
Beta Diversity (Abundance, quant=false)0.13470.1252
Beta Diversity (Presence, quant=false)0.13470.1252
Spatial Beta Diversity (Abundance, quant=true)3.91784.1093
Spatial Beta Diversity (Abundance, quant=false)3.51702.6637
Spatial Beta Diversity (Presence, quant=false)3.51702.6637
Temporal Beta Diversity (Abundance, quant=true)16.883016.8787
Temporal Beta Diversity (Abundance, quant=false)5.65845.1676
Temporal Beta Diversity (Presence, quant=false)5.65845.1676
Dispersal-niche continuum index782.059177.7877
Occupied Patches Proportion1.90951.9928
Variability Metrics12.457360.2264
Hypervolume Estimation0.01220.0022
Hypervolume Dissimilarity0.01680.0145

Benchmarked using Medium Dataset

The test case with the biggest memory usage difference between Julia and R is highligthed.

Test CaseJuliaR
Beta Diversity (Abundance, quant=true)0.24860.0357
Beta Diversity (Abundance, quant=false)0.10860.0798
Beta Diversity (Presence, quant=false)0.10860.0798
Spatial Beta Diversity (Abundance, quant=true)2.38892.2737
Spatial Beta Diversity (Abundance, quant=false)1.99081.8307
Spatial Beta Diversity (Presence, quant=false)1.99081.8307
Temporal Beta Diversity (Abundance, quant=true)15.276116.2510
Temporal Beta Diversity (Abundance, quant=false)4.13214.5399
Temporal Beta Diversity (Presence, quant=false)4.13214.5399
Dispersal-niche continuum index543.069859.2854
Occupied Patches Proportion0.99381.3995
Variability Metrics7.674632.5536
Hypervolume Estimation0.00850.0011
Hypervolume Dissimilarity0.01200.0077

Benchmarked using Small Dataset

The test case with the biggest memory usage difference between Julia and R is highligthed.

Test CaseJuliaR
Beta Diversity (Abundance, quant=true)0.12200.0195
Beta Diversity (Abundance, quant=false)0.08830.0444
Beta Diversity (Presence, quant=false)0.08830.0444
Spatial Beta Diversity (Abundance, quant=true)1.13261.2127
Spatial Beta Diversity (Abundance, quant=false)0.76600.7697
Spatial Beta Diversity (Presence, quant=false)0.76600.7697
Temporal Beta Diversity (Abundance, quant=true)12.880315.4342
Temporal Beta Diversity (Abundance, quant=false)2.89343.7231
Temporal Beta Diversity (Presence, quant=false)2.89343.7231
Dispersal-niche continuum index192.601011.1107
Occupied Patches Proportion0.26100.4932
Variability Metrics3.848310.5805
Hypervolume Estimation**0.00590.0003
Hypervolume Dissimilarity0.00820.0014

Datesets used for this benchmark

Large Dataset

53352×12 DataFrame
   Row │ Year   Month  Day    Sampling_date_order  plot   Species  Abundance  Presence  Latitude  Longitude  standardized_temperature  standardized_precipitation 
       │ Int64  Int64  Int64  Int64                Int64  String3  Int64      Int64     Float64   Float64    Float64                 Float64                  
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
     1 │  2010      1     16                    1      1  BA               0         0      35.0     -110.0                0.829467              -1.4024
     2 │  2010      1     16                    1      2  BA               0         0      35.0     -109.5               -1.12294               -0.0519895
     3 │  2010      1     16                    1      4  BA               0         0      35.0     -108.5               -0.409808              -0.803663
     4 │  2010      1     16                    1      8  BA               0         0      35.5     -109.5               -1.35913               -0.646369
     5 │  2010      1     16                    1      9  BA               0         0      35.5     -109.0                0.0822                 1.09485
   ⋮   │   ⋮      ⋮      ⋮             ⋮             ⋮       ⋮         ⋮         ⋮         ⋮          ⋮                ⋮                        ⋮
 53348 │  2023      3     21                  117      9  SH               0         0      35.5     -109.0               -0.571565              -0.836345
 53349 │  2023      3     21                  117     10  SH               0         0      35.5     -108.5               -2.33729               -0.398522
 53350 │  2023      3     21                  117     12  SH               1         1      35.5     -107.5                0.547169               1.03257
 53351 │  2023      3     21                  117     16  SH               0         0      36.0     -108.5               -0.815015               0.95971
 53352 │  2023      3     21                  117     23  SH               0         0      36.5     -108.0                0.48949               -1.59416
                                                                                                                                            53342 rows omitted

Medium Dataset

26676×12 DataFrame
   Row │ Year   Month  Day    Sampling_date_order  plot   Species  Abundance  Presence  Latitude  Longitude  standardized_temperature  standardized_precipitation 
       │ Int64  Int64  Int64  Int64                Int64  String3  Int64      Int64     Float64   Float64    Float64                 Float64                  
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
     1 │  2015      7     18                   56     12  PM               0         0      35.5     -107.5              -1.30965                  0.967859
     2 │  2016      8      6                   66     13  SF               0         0      36.0     -110.0               1.45692                  1.77253
     3 │  2017      2     25                   71     21  SF               0         0      36.5     -109.0              -1.50086                  0.993311
     4 │  2018      5     19                   82     16  PB               0         0      36.0     -108.5              -1.2202                   0.684295
   ⋮   │   ⋮      ⋮      ⋮             ⋮             ⋮       ⋮         ⋮         ⋮         ⋮          ⋮                ⋮                        ⋮
 26673 │  2010     11      6                    8     13  BA               0         0      36.0     -110.0              -1.05336                 -0.250324
 26674 │  2013      9     14                   36     12  NA               0         0      35.5     -107.5               0.213222                 0.12
 26675 │  2023      2     18                  116     12  DS               0         0      35.5     -107.5              -0.217475                 0.042571
 26676 │  2014     11     22                   49     13  PF               0         0      36.0     -110.0               0.613491                -1.17076
                                                                                                                                            26668 rows omitted

Small Dataset

5335×12 DataFrame
  Row │ Year   Month  Day    Sampling_date_order  plot   Species  Abundance  Presence  Latitude  Longitude  standardized_temperature  standardized_precipitation 
      │ Int64  Int64  Int64  Int64                Int64  String3  Int64      Int64     Float64   Float64    Float64                 Float64                  
──────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    1 │  2015      7     18                   56     12  PM               0         0      35.5     -107.5               -1.30965                 0.967859
    2 │  2016      8      6                   66     13  SF               0         0      36.0     -110.0                1.45692                 1.77253
    3 │  2017      2     25                   71     21  SF               0         0      36.5     -109.0               -1.50086                 0.993311
    4 │  2018      5     19                   82     16  PB               0         0      36.0     -108.5               -1.2202                  0.684295
  ⋮   │   ⋮      ⋮      ⋮             ⋮             ⋮       ⋮         ⋮         ⋮         ⋮          ⋮                ⋮                        ⋮
 5332 │  2013     11      2                   37     13  RF               0         0      36.0     -110.0                2.07639                 2.72841
 5333 │  2018     11     10                   88      6  PH               0         0      35.0     -107.5               -0.197006                0.842547
 5334 │  2018      3     24                   80      2  DS               0         0      35.0     -109.5               -0.920093               -0.276074
 5335 │  2014      4     26                   42      7  PH               0         0      35.5     -110.0                0.848755               -0.247144
                                                                                                                                            5327 rows omitted

Remarks

  • For DNCI_multigroup_result, 100 permutations per sample are used in both the Julia and R implementation, and parallelComputing was set to be TRUE when benchmarking DNCImper:::DNCI_multigroup() in R.

The Scripts Used for Benchmarking

Packages used for benchmarking