<commit_before>/*******************************************************************************
 * benchmarks/data/data_generators.hpp
 *
 * Part of Project c7a.
 *
 * Copyright (C) 2015 <NAME> <<EMAIL>>
 *
 * This file has no license. Only Chuck Norris can compile it.
 ******************************************************************************/

using Tuple  = std::pair<std::string, int>;
using Triple = std::tuple<std::string, int, std::string>;

template <typename Type>
std::vector<Type> generate(size_t bytes, size_t min_size, size_t max_size)
{ }

template <>
std::vector<std::string> generate(size_t bytes, size_t min_size, size_t max_size) {
    std::vector<std::string> result;
    size_t remaining = bytes;

    //init randomness
    std::random_device rd;
    std::default_random_engine randomness(rd());
    std::uniform_int_distribution<size_t> uniform_dist(min_size, max_size);

    while (remaining > 0) {
        size_t next_size = std::min(uniform_dist(randomness), remaining);
        remaining -= next_size;
        result.emplace_back(std::string('f', next_size));
    }
    return result;
}

template <>
std::vector<Tuple> generate(size_t bytes, size_t min_size, size_t max_size) {
    std::vector<Tuple> result;
    size_t remaining = bytes;

    //init randomness
    std::random_device rd;
    std::default_random_engine randomness(rd());
    std::uniform_int_distribution<size_t> uniform_dist(min_size, max_size);

    while (remaining > 0) {
        remaining -= sizeof(int);
        size_t next_size = std::min(uniform_dist(randomness), remaining);
        remaining -= next_size;
        result.push_back(Tuple(std::string('f', next_size), 42));
    }
    return result;
}

template <>
std::vector<Triple> generate(size_t bytes, size_t min_size, size_t max_size) {
    std::vector<Triple> result;
    size_t remaining = bytes;

    //init randomness
    std::random_device rd;
    std::default_random_engine randomness(rd());
    std::uniform_int_distribution<size_t> uniform_dist(min_size, max_size);

    while (remaining > 0) {
        remaining -= sizeof(int);
        size_t next_size1 = std::min(uniform_dist(randomness), remaining);
        remaining -= next_size1;
        size_t next_size2 = std::min(uniform_dist(randomness), remaining);
        remaining -= next_size2;
        result.push_back(Triple(std::string('f', next_size1), 42, std::string('g', next_size2)));
    }
    return result;
}

template <>
std::vector<int> generate(size_t bytes, size_t /*min_size*/, size_t /*max_size*/) {
    assert(bytes % sizeof(int) == 0);
    std::vector<int> result;

    for (size_t current = 0; current < bytes; current += sizeof(int)) {
        result.emplace_back(42);
    }
    return result;
}<commit_msg>use numerical limits for int<commit_after>/*******************************************************************************
 * benchmarks/data/data_generators.hpp
 *
 * Part of Project c7a.
 *
 * Copyright (C) 2015 <NAME> <<EMAIL>>
 *
 * This file has no license. Only Chuck Norris can compile it.
 ******************************************************************************/
#include <limits>

using Tuple  = std::pair<std::string, int>;
using Triple = std::tuple<std::string, int, std::string>;

template <typename Type>
std::vector<Type> generate(size_t bytes, size_t min_size, size_t max_size)
{ }

template <>
std::vector<std::string> generate(size_t bytes, size_t min_size, size_t max_size) {
    std::vector<std::string> result;
    size_t remaining = bytes;

    //init randomness
    std::random_device rd;
    std::default_random_engine randomness(rd());
    std::uniform_int_distribution<size_t> uniform_dist(min_size, max_size);

    while (remaining > 0) {
        size_t next_size = std::min(uniform_dist(randomness), remaining);
        remaining -= next_size;
        result.emplace_back(std::string('f', next_size));
    }
    return result;
}

template <>
std::vector<Tuple> generate(size_t bytes, size_t min_size, size_t max_size) {
    std::vector<Tuple> result;
    size_t remaining = bytes;

    //init randomness
    std::random_device rd;
    std::default_random_engine randomness(rd());
    std::uniform_int_distribution<size_t> uniform_dist(min_size, max_size);

    while (remaining > 0) {
        remaining -= sizeof(int);
        size_t next_size = std::min(uniform_dist(randomness), remaining);
        remaining -= next_size;
        result.push_back(Tuple(std::string('f', next_size), 42));
    }
    return result;
}

template <>
std::vector<Triple> generate(size_t bytes, size_t min_size, size_t max_size) {
    std::vector<Triple> result;
    size_t remaining = bytes;

    //init randomness
    std::random_device rd;
    std::default_random_engine randomness(rd());
    std::uniform_int_distribution<size_t> uniform_dist(min_size, max_size);

    while (remaining > 0) {
        remaining -= sizeof(int);
        size_t next_size1 = std::min(uniform_dist(randomness), remaining);
        remaining -= next_size1;
        size_t next_size2 = std::min(uniform_dist(randomness), remaining);
        remaining -= next_size2;
        result.push_back(Triple(std::string('f', next_size1), 42, std::string('g', next_size2)));
    }
    return result;
}

//! Generates random integers in the whole int-range
template <>
std::vector<int> generate(size_t bytes, size_t /*min_size*/, size_t /*max_size*/) {
    assert(bytes % sizeof(int) == 0);
    std::vector<int> result;

    //init randomness
    std::random_device rd;
    std::default_random_engine randomness(rd());
    std::uniform_int_distribution<size_t> uniform_dist(std::numeric_limits<int>::min(), std::numeric_limits<int>::max());

    for (size_t current = 0; current < bytes; current += sizeof(int)) {
        result.emplace_back(42);
    }
    return result;
}
{'fraction_non_alphanumeric': 0.1831811132173014, 'fraction_numerical': 0.007582285024987076, 'mean_word_length': 4.285974499089253, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 57, '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': '4494176', 'n_tokens_mistral': 1877, 'n_tokens_neox': 1800, 'n_words': 390}