async function getMetricTypesAndPluginsSizesByPlatform()

in automation/size/docs.js [20:55]


async function getMetricTypesAndPluginsSizesByPlatform(platform) {
  // Get the size of the library without any extras.
  const baseSize = await getCustomLibSize(platform);

  const metricTypesSizes = {};
  for (const type of METRIC_TYPES) {
    const size = await getCustomLibSize(platform, [type]);
    const sizeDiff = size - baseSize;

    // If there is (almost) no size difference,
    // the metric type is already included in the core
    // and doesn't matter for this docs.
    if (sizeDiff > 50) {
      metricTypesSizes[type] = formatBytes(sizeDiff);
    }
  }

  const pluginsSizes = {};
  for (const plugin of PLUGINS) {
    const size = await getCustomLibSize(platform, [], [plugin]);
    const sizeDiff = size - baseSize;

    // If there is (almost) no size difference,
    // the metric type is already included in the core
    // and doesn't matter for this docs.
    if (sizeDiff > 50) {
      pluginsSizes[plugin] = formatBytes(sizeDiff);
    }
  }

  return {
    baseSize: formatBytes(baseSize),
    metricTypesSizes,
    pluginsSizes,
  }
}