def get_dir_size(self, path) -> float:
        """
        Obtains the size of the given directory, in KiB.

        :param path: The path of an existing directory.
        :return: A float value describing the size (in KiB)
            of the directory as the sum of all its elements.
        """

        start = time.time()
        total_size = 0.0

        if platform == "linux" or platform == "linux2":
            total_size = (
                float(
                    subprocess.check_output(["du", "-sb", path])
                    .split()[0]
                    .decode("utf-8")
                )
                / 1024
            )
        else:
            for dirpath, dirnames, filenames in os.walk(path):
                for f in filenames:
                    fp = os.path.join(dirpath, f)
                    # skip if it is symbolic link
                    if not os.path.islink(fp):
                        # in KB
                        s = os.path.getsize(fp) / 1024
                        total_size += s

        end = time.time()
        elapsed_t = end - start
        # if we wait for more than 1 sec.
        if elapsed_t > 0.5 and self._warning_sent is False:
            print(f"\n\nWARNING: Time to get size of {path}: {elapsed_t}")
            print("Are you sure you want to monitor this directory?\n")
            self._warning_sent = True

        return total_size

        Obtains the size of the given directory, in KiB.

        :param path: The path of an existing directory.
        :return: A float value describing the size (in KiB)
            of the directory as the sum of all its elements.
        
avalanche/evaluation/metrics/disk_usage.py