1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00
This commit is contained in:
tg(x) 2011-11-12 11:35:37 +01:00
parent 1cc58abd0e
commit d95aa7f3e7

View file

@ -9,7 +9,9 @@
#define NELEMS 100
int main (int argc, char **argv) {
int
main (int argc, char **argv)
{
uint8_t verbose = argc > 1;
int i, k, n, ret;
@ -21,19 +23,28 @@ int main (int argc, char **argv) {
struct timeval start, end;
for (i=0; i<NELEMS; i++)
elems_text[i] = (PsycString) PSYC_C2STR("1234567890abcdefghijklmnopqrstuvwxyz-._ 1234567890abcdefghijklmnopqrstuvwxyz-._ 1234567890abcdefghijklmnopqrstuvwxyz-._ 1234567890");
elems_text[i] = PSYC_C2STR("1234567890abcdefghijklmnopqrstuvwxyz-._ "
"1234567890abcdefghijklmnopqrstuvwxyz-._ "
"1234567890abcdefghijklmnopqrstuvwxyz-._ "
"1234567890");
for (i=0; i<NELEMS; i++)
elems_bin[i] = (PsycString) PSYC_C2STR("1234567890|abcdefghijklmnopqrstuvwxyz|_\n1234567890|abcdefghijklmnopqrstuvwxyz|_\n1234567890|abcdefghijklmnopqrstuvwxyz|_\n1234567890");
elems_bin[i] = PSYC_C2STR("1234567890|abcdefghijklmnopqrstuvwxyz|_\n"
"1234567890|abcdefghijklmnopqrstuvwxyz|_\n"
"1234567890|abcdefghijklmnopqrstuvwxyz|_\n"
"1234567890");
psyc_list_init(&list_text, elems_text, PSYC_NUM_ELEM(elems_text), PSYC_LIST_NO_LENGTH);
psyc_list_init(&list_bin, elems_bin, PSYC_NUM_ELEM(elems_bin), PSYC_LIST_CHECK_LENGTH);
psyc_list_init(&list_text, elems_text, PSYC_NUM_ELEM(elems_text),
PSYC_LIST_NO_LENGTH);
psyc_list_init(&list_bin, elems_bin, PSYC_NUM_ELEM(elems_bin),
PSYC_LIST_CHECK_LENGTH);
psyc_render_list(&list_text, buf_text, sizeof(buf_text));
psyc_render_list(&list_bin, buf_bin, sizeof(buf_bin));
printf("list_text: %ld\n%.*s\n", list_text.length, (int)list_text.length, buf_text);
printf("list_bin: %ld\n%.*s\n", list_bin.length, (int)list_bin.length, buf_bin);
printf("list_text: %ld\n%.*s\n",
list_text.length, (int)list_text.length, buf_text);
printf("list_bin: %ld\n%.*s\n",
list_bin.length, (int)list_bin.length, buf_bin);
#if 1
printf("parsing text list to elems[]\n");
@ -48,7 +59,8 @@ int main (int argc, char **argv) {
case PSYC_PARSE_LIST_END:
ret = 0;
case PSYC_PARSE_LIST_ELEM:
if (verbose) printf("|%d: %.*s... (%ld)\n", i, 10, elem.data, elem.length);
if (verbose)
printf("|%d: %.*s... (%ld)\n", i, 10, elem.data, elem.length);
//elems[i] = malloc(elem.length);
//memcpy(&elems[i++], elem.data, elem.length);
break;
@ -59,8 +71,10 @@ int main (int argc, char **argv) {
} while (ret > 0);
}
gettimeofday(&end, NULL);
//printf("%ld ms\n", (end.tv_sec * 1000000 + end.tv_usec - start.tv_sec * 1000000 - start.tv_usec) / 1000);
printf("%ld us\n", (end.tv_sec * 1000000 + end.tv_usec - start.tv_sec * 1000000 - start.tv_usec));
// printf("%ld ms\n", (end.tv_sec * 1000000 + end.tv_usec
// - start.tv_sec * 1000000 - start.tv_usec) / 1000);
printf("%ld us\n", (end.tv_sec * 1000000 + end.tv_usec
- start.tv_sec * 1000000 - start.tv_usec));
#endif
#if 1
@ -88,8 +102,10 @@ int main (int argc, char **argv) {
} while (ret > 0);
}
gettimeofday(&end, NULL);
//printf("%ld ms\n", (end.tv_sec * 1000000 + end.tv_usec - start.tv_sec * 1000000 - start.tv_usec));
printf("%ld us\n", (end.tv_sec * 1000000 + end.tv_usec - start.tv_sec * 1000000 - start.tv_usec));
// printf("%ld ms\n", (end.tv_sec * 1000000 + end.tv_usec
// - start.tv_sec * 1000000 - start.tv_usec));
printf("%ld us\n", (end.tv_sec * 1000000 + end.tv_usec
- start.tv_sec * 1000000 - start.tv_usec));
#endif
#if 1
@ -120,8 +136,10 @@ int main (int argc, char **argv) {
} while (ret > 0);
}
gettimeofday(&end, NULL);
//printf("%ld ms\n", (end.tv_sec * 1000000 + end.tv_usec - start.tv_sec * 1000000 - start.tv_usec));
printf("%ld us\n", (end.tv_sec * 1000000 + end.tv_usec - start.tv_sec * 1000000 - start.tv_usec));
// printf("%ld ms\n", (end.tv_sec * 1000000 + end.tv_usec
// - start.tv_sec * 1000000 - start.tv_usec));
printf("%ld us\n", (end.tv_sec * 1000000 + end.tv_usec
- start.tv_sec * 1000000 - start.tv_usec));
#endif
#if 1
@ -154,8 +172,10 @@ int main (int argc, char **argv) {
} while (ret > 0);
}
gettimeofday(&end, NULL);
//printf("%ld ms\n", (end.tv_sec * 1000000 + end.tv_usec - start.tv_sec * 1000000 - start.tv_usec));
printf("%ld us\n", (end.tv_sec * 1000000 + end.tv_usec - start.tv_sec * 1000000 - start.tv_usec));
// printf("%ld ms\n", (end.tv_sec * 1000000 + end.tv_usec
// - start.tv_sec * 1000000 - start.tv_usec));
printf("%ld us\n", (end.tv_sec * 1000000 + end.tv_usec
- start.tv_sec * 1000000 - start.tv_usec));
#endif
#if 1
@ -200,8 +220,10 @@ int main (int argc, char **argv) {
} while (ret > 0);
}
gettimeofday(&end, NULL);
//printf("%ld ms\n", (end.tv_sec * 1000000 + end.tv_usec - start.tv_sec * 1000000 - start.tv_usec));
printf("%ld us\n", (end.tv_sec * 1000000 + end.tv_usec - start.tv_sec * 1000000 - start.tv_usec));
// printf("%ld ms\n", (end.tv_sec * 1000000 + end.tv_usec
// - start.tv_sec * 1000000 - start.tv_usec));
printf("%ld us\n", (end.tv_sec * 1000000 + end.tv_usec
- start.tv_sec * 1000000 - start.tv_usec));
#endif
return 0;