Example #1
0
char *test_find_performance()
{
    int i = 0;
    int found_at = 0;
    unsigned long find_count = 0;
    time_t elapsed = 0;

    found_at = String_find(&IN_STR, &ALPHA);


    time_t start = time(NULL);

    do {
        for(i = 0; i < 1000; i++) {
            found_at = String_find(&IN_STR, list->entry[i % list->mlen]);
            find_count++;
        }

        elapsed = time(NULL) - start;
    } while(elapsed <= TEST_TIME);

    debug("FIND COUNT: %lu, END TIME: %d, OPS: %f",
            find_count, (int)elapsed, (double)find_count / elapsed);

    return NULL;
}
Example #2
0
char *test_find_and_scan()
{
    StringScanner *scan = StringScanner_create(&IN_STR);
    mu_assert(scan != NULL, "Failed to make the scanner.");

    int find_i = String_find(&IN_STR, &ALPHA);
    mu_assert(find_i > 0, "Failed to find 'ALPHA' in test string.");

    int scan_i = StringScanner_scan(scan, &ALPHA);
    mu_assert(scan_i > 0, "Failed to find 'ALPHA' with scan.");
    mu_assert(scan_i == find_i, "find and scan don't match");

    scan_i = StringScanner_scan(scan, &ALPHA);
    mu_assert(scan_i > find_i,
            "should find another ALPHA after the first");

    scan_i = StringScanner_scan(scan, &ALPHA);
    mu_assert(scan_i > find_i,
            "should find another ALPHA after the first");

    mu_assert(StringScanner_scan(scan, &ALPHA) == -1,
            "shouldn't find it");

    StringScanner_destroy(scan);

    return NULL;
}
Example #3
0
char *test_find_and_scan() {
    StringScanner *scan = StringScanner_create(&IN_STR);
    mu_assert(scan != NULL, "Failed to make the scanner.");

    int find_i = String_find(&IN_STR, &ALPHA);
    mu_assert(find_i > 0, "Failed to find 'ALPHA' in test string.");

    int scan_i = StringScanner_scan(scan, &ALPHA);
    mu_assert(scan_i > 0, "Failed to find 'ALPHA' with scan.");
    mu_assert(scan_i == find_i, "Find and Scan don't match.");

    scan_i = StringScanner_scan(scan, &ALPHA);
    mu_assert(scan_i > find_i, "Should find a second 'ALPHA' after the first.");

    scan_i = StringScanner_scan(scan, &ALPHA);
    mu_assert(scan_i > find_i, "Should find third 'ALPHA' after the first.");

    mu_assert(StringScanner_scan(scan, &ALPHA) == -1,
            "Shouldn't find a fourth 'ALPHA' after the third.");

    StringScanner_destroy(scan);

    return NULL;
}
char* test_find_performance()
{
  int i = 0;
  int found_at = 0;
  unsigned long find_count = 0;
  time_t elapsed = 0;
  time_t start = time(NULL);

  do {
    for (i = 0; i < 1000; ++i) {
      found_at = String_find(&IN_STR, &ALPHA);
      mu_assert(found_at > 0, "Failed to find!");

      ++find_count;
    }
    
    elapsed = time(NULL) - start;
  } while (elapsed <= TEST_TIME);

  debug("FIND COUNT: %lu, END TIME: %d, OPS: %f",
        find_count, (int) elapsed, (double) find_count / elapsed);

  return NULL;
}
char *test_find_performance()
{

  srand(time(NULL));

  int i = 0;
  int found_at = 0;
  unsigned long find_count = 0;
  time_t elapsed = 0;
  time_t start = time(NULL);
  int j  = 0;

  Stats *st = Stats_create();

  while (j <=10) {
    do {
      for(i = 0; i < 1000; i++) {
        found_at = String_find(&IN_STR, &ALPHA);
        find_count++;
      }

      elapsed = time(NULL) - start;
      Stats_sample(st, (double)find_count);
    } while(elapsed <= TEST_TIME);
    i = 0;
    found_at = 0;
    find_count = 0;
    elapsed = 0;
    start = time(NULL);
    j++;
  }

  Stats_dump(st);

  return NULL;
}