Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/klib/blob/master/test/kseq_bench2.c # klib [Ported from github.com/attractivechaos/klib] added block arena Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `klib / test / kseq_bench2.c` 44 lines ยท 880 bytes Raw Blame History 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include "kseq.h" 8 KSTREAM_INIT(int, read, 4096) 9 10 #define BUF_SIZE 65536 11 12 int main(int argc, char *argv[]) 13 { 14 clock_t t; 15 if (argc == 1) { 16 fprintf(stderr, "Usage: %s \n", argv[0]); 17 return 1; 18 } 19 { 20 FILE *fp; 21 char *s; 22 t = clock(); 23 s = malloc(BUF_SIZE); 24 fp = fopen(argv[1], "r"); 25 while (fgets(s, BUF_SIZE, fp)); 26 fclose(fp); 27 fprintf(stderr, "[fgets] %.2f sec\n", (float)(clock() - t) / CLOCKS_PER_SEC); 28 } 29 { 30 int fd, dret; 31 kstream_t *ks; 32 kstring_t s; 33 t = clock(); 34 s.l = s.m = 0; s.s = 0; 35 fd = open(argv[1], O_RDONLY); 36 ks = ks_init(fd); 37 while (ks_getuntil(ks, '\n', &s, &dret) >= 0); 38 free(s.s); 39 ks_destroy(ks); 40 close(fd); 41 fprintf(stderr, "[kstream] %.2f sec\n", (float)(clock() - t) / CLOCKS_PER_SEC); 42 } 43 return 0; 44 }