limit fstBC to 30bp in Python3 ver.
[GalaxyCodeBases.git] / c_cpp / lib / klib / test / kstring_bench.c
blob82598e88cfe0f305a278da78d490ce9459c41d54
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <time.h>
4 #include "kstring.h"
6 #define N 10000000
8 int main()
10 int i;
11 clock_t t;
12 kstring_t s, s2;
13 srand48(11);
14 s.l = s.m = 0; s.s = 0;
15 t = clock();
16 for (i = 0; i < N; ++i) {
17 int x = lrand48();
18 s.l = 0;
19 kputw(x, &s);
21 fprintf(stderr, "kputw: %lf\n", (double)(clock() - t) / CLOCKS_PER_SEC);
22 srand48(11);
23 t = clock();
24 for (i = 0; i < N; ++i) {
25 int x = lrand48();
26 s.l = 0;
27 ksprintf(&s, "%d", x);
29 fprintf(stderr, "ksprintf: %lf\n", (double)(clock() - t) / CLOCKS_PER_SEC);
31 srand48(11);
32 s2.l = s2.m = 0; s2.s = 0;
33 t = clock();
34 for (i = 0; i < N; ++i) {
35 int x = lrand48();
36 s2.l = s.l = 0;
37 kputw(x, &s2);
38 kputs(s2.s, &s);
40 fprintf(stderr, "kputw+kputs: %lf\n", (double)(clock() - t) / CLOCKS_PER_SEC);
41 srand48(11);
42 t = clock();
43 for (i = 0; i < N; ++i) {
44 int x = lrand48();
45 s2.l = s.l = 0;
46 kputw(x, &s2);
47 ksprintf(&s, "%s", s2.s);
49 fprintf(stderr, "kputw+ksprintf: %lf\n", (double)(clock() - t) / CLOCKS_PER_SEC);
50 return 0;