<commit_before>package org.mitre.synthea;

import org.mitre.synthea.world.agents.Person;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

public class ParallelTestingService {
  public static List<String> runInParallel(PersonTester pt) throws Exception {
    ExecutorService service = Executors.newFixedThreadPool(6);
    List<String> validationErrors = new ArrayList<>();
    int numberOfPeople = 10;
    TestHelper.getGeneratedPerson(1);
    List<Future<Exception>> potentialCrashes = new ArrayList<>(10);
    for (int i = 0; i < numberOfPeople; i++) {
      Person person = TestHelper.getGeneratedPerson(i);
      Future<Exception> maybeCrash = service.submit(() -> {
        try {
          validationErrors.addAll(pt.test(person));
          return null;
        } catch (Exception e) {
          return e;
        }
      });
      potentialCrashes.add(i, maybeCrash);
    }
    service.shutdown();
    service.awaitTermination(1, TimeUnit.HOURS);
    for (int i = 0; i < potentialCrashes.size(); i++) {
      Future<Exception> potentalCrash = potentialCrashes.get(i);
      Exception e = potentalCrash.get();
      if (e != null) {
        throw e;
      }
    }
    return validationErrors;
  }
}
<commit_msg>WIP: Adding logging to the parallel testing<commit_after>package org.mitre.synthea;

import org.mitre.synthea.world.agents.Person;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

public class ParallelTestingService {
  public static List<String> runInParallel(PersonTester pt) throws Exception {
    ExecutorService service = Executors.newFixedThreadPool(6);
    List<String> validationErrors = new ArrayList<>();
    int numberOfPeople = 10;
    TestHelper.getGeneratedPerson(1);
    List<Future<Exception>> potentialCrashes = new ArrayList<>(10);
    for (int i = 0; i < numberOfPeople; i++) {
      Person person = TestHelper.getGeneratedPerson(i);
      final int counter = i;
      Future<Exception> maybeCrash = service.submit(() -> {
        long start = System.currentTimeMillis();
        System.out.println(String.format("Starting person %d at %d", counter, start));
        try {
          validationErrors.addAll(pt.test(person));
          return null;
        } catch (Exception e) {
          return e;
        } finally {
          long end = System.currentTimeMillis();
          long duration = end - start;
          System.out.println(String.format("Finished %d at %d, which took %d", counter,
              end, duration));
        }
      });
      potentialCrashes.add(i, maybeCrash);
    }
    service.shutdown();
    service.awaitTermination(1, TimeUnit.HOURS);
    for (int i = 0; i < potentialCrashes.size(); i++) {
      Future<Exception> potentalCrash = potentialCrashes.get(i);
      Exception e = potentalCrash.get();
      if (e != null) {
        throw e;
      }
    }
    return validationErrors;
  }
}

{'fraction_non_alphanumeric': 0.11729559748427673, 'fraction_numerical': 0.005660377358490566, 'mean_word_length': 3.1365409622886866, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, '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': '5829609', 'n_tokens_mistral': 948, 'n_tokens_neox': 929, 'n_words': 214}