<commit_before>//
// Created by nebula on 7/15/17.
//

#include <stdlib.h>
#include <time.h>
#include "benchmark.h"


extern "C" {

#ifdef USE_FLOAT
#define EXP(x) expf((x))
typedef float FLOAT;
#else
#define EXP(x) exp((x))
typedef double FLOAT;
#endif

double getTime();
void init_array(int size, FLOAT *array, FLOAT value);
void init_array_rand(int size, FLOAT *array, FLOAT max);

double getTime()
{
//    struct timeval tv;
//    gettimeofday(&tv, NULL);
//    return(tv.tv_sec + (double)tv.tv_usec*1e-6);

    struct timespec ts;
    clock_gettime(CLOCK_REALTIME, &ts);
    return(ts.tv_sec + ts.tv_nsec*1e-9);
}


void init_array(int size, FLOAT *array, FLOAT value) {
    for (int i = 0; i < size; i++) { array[i] = value; }
}

void init_array_rand(int size, FLOAT *array, FLOAT max) {
    srand((unsigned)time(NULL));
    for (int i = 0; i < size; i++) { array[i] = ((double)rand() / ((double)RAND_MAX + 1)) * max; }
}

void triad_core(int array_size, FLOAT *a, FLOAT *b, FLOAT *c)
{
    FLOAT scalar = 3.141592;
    for (int i; i<array_size; i++){
        a[i] = b[i] + scalar * c[i];
    }
}

double benchmark_triad(int size) {<commit_msg>restruct benchmark code<commit_after>//
// Created by nebula on 7/15/17.
//

#include <stdlib.h>
#include <time.h>
#include "benchmark.h"


extern "C" {

#ifdef USE_FLOAT
#define EXP(x) expf((x))
typedef float FLOAT;
#else
#define EXP(x) exp((x))
typedef double FLOAT;
#endif

double getTime();
void init_array(int size, FLOAT *array, FLOAT value);
void init_array_rand(int size, FLOAT *array, FLOAT max);

double getTime()
{
    struct timespec ts;
    clock_gettime(CLOCK_REALTIME, &ts);
    return(ts.tv_sec + ts.tv_nsec*1e-9);
}


void init_array(int size, FLOAT *array, FLOAT value) {
    for (int i = 0; i < size; i++) { array[i] = value; }
}

void init_array_rand(int size, FLOAT *array, FLOAT max) {
    srand((unsigned)time(NULL));
    for (int i = 0; i < size; i++) { array[i] = ((double)rand() / ((double)RAND_MAX + 1)) * max; }
}

void triad_core(int array_size, FLOAT *a, FLOAT *b, FLOAT *c)
{
    FLOAT scalar = 3.141592;
    for (int i; i<array_size; i++){
        a[i] = b[i] + scalar * c[i];
    }
}

double benchmark_triad(int size) {
{'fraction_non_alphanumeric': 0.16984559491371481, 'fraction_numerical': 0.01634877384196185, 'mean_word_length': 3.7173447537473234, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, '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': '6789946', 'n_tokens_mistral': 962, 'n_tokens_neox': 913, 'n_words': 239}