### Question:
Cohort extends BaseChangeableOpenmrsData { @Deprecated public void setMemberIds(Set<Integer> memberIds) { if (getMemberships().isEmpty()) { for (Integer id : memberIds) { addMembership(new CohortMembership(id)); } } else { throw new IllegalArgumentException("since 2.1.0 cohorts are more complex than just a set of patient ids"); } } Cohort();  Cohort(Integer cohortId);  Cohort(String name, String description, Integer[] ids);  Cohort(String name, String description, Patient[] patients);  Cohort(Collection<?> patientsOrIds);  Cohort(String name, String description, Collection<?> patientsOrIds);  Cohort(String commaSeparatedIds); @Deprecated String getCommaSeparatedPatientIds(); boolean contains(Integer patientId); @Override String toString(); void addMember(Integer memberId); boolean addMembership(CohortMembership cohortMembership); boolean removeMembership(CohortMembership cohortMembership); Collection<CohortMembership> getMemberships(boolean includeVoided); Collection<CohortMembership> getMemberships(); Collection<CohortMembership> getActiveMemberships(Date asOfDate); Collection<CohortMembership> getActiveMemberships(); CohortMembership getActiveMembership(Patient patient); int size(); @Deprecated int getSize(); boolean isEmpty(); static Cohort union(Cohort a, Cohort b); static Cohort intersect(Cohort a, Cohort b); static Cohort subtract(Cohort a, Cohort b); Integer getCohortId(); void setCohortId(Integer cohortId); String getDescription(); void setDescription(String description); String getName(); void setName(String name); @Deprecated Set<Integer> getMemberIds(); @Deprecated void setMemberIds(Set<Integer> memberIds); void setMemberships(Collection<CohortMembership> members); @Override Integer getId(); @Override void setId(Integer id); static final long serialVersionUID; }### Answer:
@Test public void setMemberIds_shouldSupportLargeCohorts() { int cohortSize = 100000; Cohort c = new Cohort(); Set<Integer> ids = new HashSet<Integer>(); for (int i=0; i<cohortSize; i++) { ids.add(i); } long startTime = System.currentTimeMillis(); c.setMemberIds(ids); long endTime = System.currentTimeMillis(); double secondsToSet = (endTime - startTime)/1000; Assert.assertTrue("Setting cohort of size " + cohortSize + " took " + secondsToSet + " seconds", secondsToSet < 5); }