<commit_before>#include "lyra2.h"
#include <stdio.h>

#include <string.h>
#include <sys/time.h>

int
main(void) {
    char key[64];
    char *pwd = "<PASSWORD>";
    char *salt = "<PASSWORD>";

    struct timeval t0;
    struct timeval t1;
    gettimeofday(&t0, 0);

    lyra2(key, sizeof(key), pwd, strlen(pwd), salt, strlen(salt), 10, 64, 10);

    gettimeofday(&t1, 0);
    unsigned long elapsed = (t1.tv_sec-t0.tv_sec) * 1000000 + t1.tv_usec-t0.tv_usec;
    printf("Execution Time: %lu us\n", elapsed);

    for (unsigned int i = 0; i < sizeof(key); i++) {
        printf("%.2x ", ((uint8_t *) key)[i]);
    }
    printf("\n");
    return 0;
}<commit_msg>Do repeated time measurements and take the median.<commit_after>#include "lyra2.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>

#define NMEASUREMENTS 1000

int
cmp(const void *xv, const void *yv) {
    unsigned long x = *((unsigned long *) xv), y = *((unsigned long *) yv);
    if (x < y) return -1;
    return x != y;
}

int
main(void) {
    char key[64];
    char *pwd = "<PASSWORD>";
    char *salt = "<PASSWORD>";
    unsigned long results[NMEASUREMENTS] = {0};

    for (int i = 0; i < NMEASUREMENTS; i++) {
        struct timeval t0;
        struct timeval t1;
        gettimeofday(&t0, 0);

        lyra2(key, sizeof(key), pwd, strlen(pwd), salt, strlen(salt), 16, 64, 10);

        gettimeofday(&t1, 0);
        results[i] = (t1.tv_sec-t0.tv_sec) * 1000000 + t1.tv_usec-t0.tv_usec;
    }

    for (unsigned int i = 0; i < sizeof(key); i++) {
        printf("%.2x ", ((uint8_t *) key)[i]);
    }
    printf("\n");

    qsort(results, NMEASUREMENTS, sizeof(results[0]), cmp);
    printf("median time: %lu us\n", results[NMEASUREMENTS/2]);

    return 0;
}
{'fraction_non_alphanumeric': 0.18088737201365188, 'fraction_numerical': 0.040386803185438, 'mean_word_length': 2.9977272727272726, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 14, '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': '6380197', 'n_tokens_mistral': 748, 'n_tokens_neox': 680, 'n_words': 174}