<commit_before><commit_msg>* Add iostat which read /proc/{pid}/io and print to human readable size<commit_after>import sys, os

def humanSize(size):
    kb = 1024
    mb = 1024 * kb
    gb = 1024 * mb
    tb = 1024 * gb
    pb = 1024 * tb
    eb = 1024 * pb
    if size == 0:
        return "0 byte"
    elif size >= eb:
        return "{:.5f} {}".format(float(size) / eb, "EiB")
    elif size >= pb:
        return "{:.4f} {}".format(float(size) / pb, "PiB")
    elif size >= tb:
        return "{:.3f} {}".format(float(size) / tb, "TiB")
    elif size >= gb:
        return "{:.2f} {}".format(float(size) / gb, "GiB")
    elif size >= mb:
        return "{:.1f} {}".format(float(size) / mb, "MiB")
    elif size >= kb:
        return "{} {}".format(size / kb, "KiB")
    else:
        return "{} {}".format(size, "bytes")


if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("usage: {} pid".format(sys.argv[0]))
        exit (1)
    pid = sys.argv[1]
    path = "/proc/{}/io".format(pid)
    if not os.path.exists(path):
        print("{} does not exist".format(path))
        exit (1)
    f = open(path)
    for line in f:
        stat, stat_bytes = line.strip().split(" ")
        print("{} {}".format(stat, humanSize(int(stat_bytes))))
{'fraction_non_alphanumeric': 0.19729514717581542, 'fraction_numerical': 0.028639618138424822, 'mean_word_length': 2.2339331619537277, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6358551', 'n_tokens_mistral': 489, 'n_tokens_neox': 449, 'n_words': 125}