<commit_before>#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include <math.h>
#include <sys/time.h>


/* Estimate time remaining based on avg. rate so far, e.g. "1h 20m 14s". */
void print_eta(FILE *f, long sec, long done, long total) {
        struct timeval tv;
        float rate;
        uint rem, h, m, s;
        if (gettimeofday(&tv, NULL) != 0) err(1, "gettimeofday");
        rate = (tv.tv_sec - sec) / (1.0 * done);
        rem = (total - done) * rate;
        h = floor(rem / 3600);
        m = floor((rem % 3600) / 60.0);
        s = floor(rem % 60);
        if (h > 0) fprintf(f, "%dh ", h);
        if (m > 0) fprintf(f, "%dm ", m);
        fprintf(f, "%ds", s);
}
<commit_msg>glean.h to eta.c, compile on darwin<commit_after>#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include <math.h>
#include <sys/time.h>

#include "glean.h"

/* Estimate time remaining based on avg. rate so far, e.g. "1h 20m 14s". */
void print_eta(FILE *f, long sec, long done, long total) {
        struct timeval tv;
        float rate;
        uint rem, h, m, s;
        if (gettimeofday(&tv, NULL) != 0) err(1, "gettimeofday");
        rate = (tv.tv_sec - sec) / (1.0 * done);
        rem = (total - done) * rate;
        h = floor(rem / 3600);
        m = floor((rem % 3600) / 60.0);
        s = floor(rem % 60);
        if (h > 0) fprintf(f, "%dh ", h);
        if (m > 0) fprintf(f, "%dm ", m);
        fprintf(f, "%ds", s);
}

{'fraction_non_alphanumeric': 0.18339100346020762, 'fraction_numerical': 0.03321799307958478, 'mean_word_length': 2.164113785557987, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '4058596', 'n_tokens_mistral': 593, 'n_tokens_neox': 555, 'n_words': 171}