<commit_before>#include <stdint.h>
#include <time.h>
#include <stdlib.h>

void main() {}

/* @brief Create an array of int64s, time the cache accessing those and return
   the timings
   @param cache_size The expected size of the cache
   @return the array representation of the timing of our cache
*/
double *test_a_cache_size(int64_t cache_size) {
  int64_t array_size = (cache_size / 8) + 1;
  int64_t arrayOfTestValues[array_size];
  for (int step = 0; step < array_size; step++) {
    arrayOfTestValues[step] = (int64_t)step;
  }
  /* Warm up the cache by moving through the array once */
  /* We need ot write a function to create a random int64 */
  int64_t x = random_int64();
  for (int i = 0; i < 10 * (array_size); i++) {
    x = x ^ arrayOfTestValues[i];
  }
  /* Time the cache by running through the array ten times */
  x = random_int64();
  double *timerArray[array_size];
  for (int i = 0; i < 10 * (arry_size); i++) {
    clock_t begin = clock();
    x = x ^ arrayOfTestValues[i];
    clock_t end = clock();
    timerArray[i] = (double)(end - begin) / CLOCK_PER_SEC;
  }
  return timerArray;
}

/* @brief Generates a random int and casts as int64
   @return returns the int64_t that was generated
*/
int64_t random_int64() {
  srand(time(NULL));
  /* Should we be using rand()? Do we need a limited range?
     Do our random int64s need to be uniform? */
  int64_t r = (int64_t)rand();
  return r;
}

/* @brief subtracts hitspeed from each time found in our time array
   @param timeArray Our timeArray found in test_a_cache_size
   @param hitspeed How long it takes for the cache to get a hit
   @param array_size The size of our array
   @return the array of our missPenalities
*/
double *findMissPenalities(double *timeArray, double hitSpeed, int64_t array_size) {
  double *missPenalties[array_size];
  for (i = 0; i < array_size, i++) {
    missPenalties[i] = timeArray[i] - hitSpeed;
  }
  return missPenalties;
}
<commit_msg>Find cache size function done @siddharthist<commit_after>#include <stdint.h>
#include <time.h>
#include <stdlib.h>

void main() {}

double *find_cache_size(int stepSize, int64_t expectedCacheSize) {
  double *timeArray[expectedCacheSize]; /* Does this need to be = (expectedCacheSize / 8) + 1 */
  srand(time(NULL);
  for(int i = 0; i < expectedCacheSize; i++) {
    int64_t arrayOfTestValues[i];
    /* Seed the array with random values */
    for (int k = 0; k < i; k++) {
      arrayOfTestValue[k] = (int64_t)rand();
    }
    int64_t x = (int64_t)rand();
    /* Warm up the array */
    for (int k = 0; k < i; k++) {
      x = x ^ arrayOfTestValue[k];
    }
    /* Time the array cache fetching for this i */
    clock_t begin = clock();
    for (int k = 0; k < i; k++) {
      x = x ^ arrayOfTestValue[k];
    }
    clock_t end = clock();
    timeArray[i] = (double)(end - begin) / CLOCKS_PER_SEC;
  }
  return timeArray;
}



/* @brief Create an array of int64s, time the cache accessing those and return
   the timings
   @param cache_size The expected size of the cache
   @return the array representation of the timing of our cache
*/
double *test_timing_of_hits_miss(int64_t cache_size) {
  int64_t array_size = (cache_size / 8) + 1;
  int64_t arrayOfTestValues[array_size];
  for (int step = 0; step < array_size; step++) {
    arrayOfTestValues[step] = (int64_t)step;
  }
  /* Warm up the cache by moving through the array once */
  /* We need ot write a function to create a random int64 */
  int64_t x = random_int64();
  for (int i = 0; i < 10 * (array_size); i++) {
    x = x ^ arrayOfTestValues[i];
  }
  /* Time the cache by running through the array ten times */
  x = random_int64();
  double *timerArray[array_size];
  for (int i = 0; i < 10 * (arry_size); i++) {
    clock_t begin = clock();
    x = x ^ arrayOfTestValues[i];
    clock_t end = clock();
    timerArray[i] = (double)(end - begin) / CLOCK_PER_SEC;
  }
  return timerArray;
}

/* @brief Generates a random int and casts as int64
   @return returns the int64_t that was generated
*/
int64_t random_int64() {
  srand(time(NULL));
  /* Should we be using rand()? Do we need a limited range?
     Do our random int64s need to be uniform? */
  int64_t r = (int64_t)rand();
  return r;
}

/* @brief subtracts hitspeed from each time found in our time array
   @param timeArray Our timeArray found in test_a_cache_size
   @param hitspeed How long it takes for the cache to get a hit
   @param array_size The size of our array
   @return the array of our missPenalities
*/
double *findMissPenalities(double *timeArray, double hitSpeed, int64_t array_size) {
  double *missPenalties[array_size];
  for (i = 0; i < array_size, i++) {
    missPenalties[i] = timeArray[i] - hitSpeed;
  }
  return missPenalties;
}

{'fraction_non_alphanumeric': 0.11272957568081064, 'fraction_numerical': 0.021954823728097952, 'mean_word_length': 3.3951762523191094, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 9, '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': '2803497', 'n_tokens_mistral': 1694, 'n_tokens_neox': 1616, 'n_words': 569}