aboutsummaryrefslogtreecommitdiff
path: root/seq-read.c
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2020-06-11 18:27:39 +0200
committerThomas Schmucker <ts@its1.de>2020-06-11 18:27:39 +0200
commit5b06a00890fe3e2c77c7c5835c975e87b8c7dfb0 (patch)
treecfe688d2c6bd3116ce81bc709f13a1fa1c68a718 /seq-read.c
downloadlibcsv-5b06a00890fe3e2c77c7c5835c975e87b8c7dfb0.tar.gz
libcsv-5b06a00890fe3e2c77c7c5835c975e87b8c7dfb0.tar.bz2
libcsv-5b06a00890fe3e2c77c7c5835c975e87b8c7dfb0.zip
erster Commit
Diffstat (limited to 'seq-read.c')
-rw-r--r--seq-read.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/seq-read.c b/seq-read.c
new file mode 100644
index 0000000..b9ef58b
--- /dev/null
+++ b/seq-read.c
@@ -0,0 +1,33 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <time.h>
4
5int
6main(void)
7{
8 clock_t start = clock();
9 size_t sum = 0;
10
11#if 0
12 int ch;
13 while ((ch = getc(stdin)) != EOF) {
14 sum += (unsigned char) ch;
15 }
16#endif
17
18#if 1
19 unsigned char buffer[1024];
20 size_t n;
21 while ((n = fread(buffer, 1, sizeof buffer, stdin)) > 0) {
22 for ( size_t z = 0; z != n; ++z ) {
23 sum += buffer[z];
24 }
25 }
26#endif
27
28 clock_t end = clock();
29
30 printf("Result: %zu, Duration: %.3lf sec\n", sum, (double)(end - start) / CLOCKS_PER_SEC);
31
32 return EXIT_SUCCESS;
33}