template<typename Hash>
int time_hash(const vector<string>& words, Hash hash) {
    clock_t before = init_timer();
    for(const string& word : words)
        hash(word);
    clock_t after = clock();
    return after - before;
}
 
void run_trial(int num_words, ofstream& md5_out, ofstream& sha1_out, ofstream& sha256_out) {
    vector<string> words;
    for(int i = 0; i < num_words; ++i)
        words.push_back(random_word(8));
 
    md5_out << time_hash(words, md5) << '\n';
    sha1_out << time_hash(words, sha1) << '\n';
    sha256_out << time_hash(words, sha256) << '\n';
}