summaryrefslogtreecommitdiff
path: root/legacy/eet/src/bin
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-05-10 13:35:33 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-05-10 13:35:33 +0000
commite600739282324644dcbc6f081fae85af0812f42e (patch)
tree0e0daa02ab5b15250018ff5444d3e82605e4344a /legacy/eet/src/bin
parent70e894091f58694fd56eab10eb0224e105929ee5 (diff)
slightly faster image load
SVN revision: 14696
Diffstat (limited to 'legacy/eet/src/bin')
-rw-r--r--legacy/eet/src/bin/Makefile.am8
-rw-r--r--legacy/eet/src/bin/eet_bench_main.c114
2 files changed, 121 insertions, 1 deletions
diff --git a/legacy/eet/src/bin/Makefile.am b/legacy/eet/src/bin/Makefile.am
index 3e8351c404..3fb463fb72 100644
--- a/legacy/eet/src/bin/Makefile.am
+++ b/legacy/eet/src/bin/Makefile.am
@@ -2,10 +2,16 @@ MAINTAINERCLEANFILES = Makefile.in
2 2
3INCLUDES = -I$(top_srcdir)/src/lib 3INCLUDES = -I$(top_srcdir)/src/lib
4 4
5bin_PROGRAMS = eet 5bin_PROGRAMS = eet eet_bench
6 6
7eet_SOURCES = \ 7eet_SOURCES = \
8eet_main.c 8eet_main.c
9 9
10eet_LDADD = $(top_builddir)/src/lib/libeet.la 10eet_LDADD = $(top_builddir)/src/lib/libeet.la
11eet_DEPENDENCIES = $(top_builddir)/src/lib/libeet.la 11eet_DEPENDENCIES = $(top_builddir)/src/lib/libeet.la
12
13eet_bench_SOURCES = \
14eet_bench_main.c
15
16eet_bench_LDADD = $(top_builddir)/src/lib/libeet.la
17eet_bench_DEPENDENCIES = $(top_builddir)/src/lib/libeet.la
diff --git a/legacy/eet/src/bin/eet_bench_main.c b/legacy/eet/src/bin/eet_bench_main.c
new file mode 100644
index 0000000000..88aa364b93
--- /dev/null
+++ b/legacy/eet/src/bin/eet_bench_main.c
@@ -0,0 +1,114 @@
1#include "Eet.h"
2#include <stdio.h>
3#include <unistd.h>
4#include <stdlib.h>
5#include <string.h>
6#include <sys/types.h>
7#include <sys/stat.h>
8#include <unistd.h>
9#include <dirent.h>
10#include <limits.h>
11#include <fnmatch.h>
12#include <sys/time.h>
13#include <time.h>
14
15double
16get_time(void)
17{
18 struct timeval timev;
19
20 gettimeofday(&timev, NULL);
21 return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
22}
23
24int
25main(int argc, char **argv)
26{
27 char *file;
28 Eet_File *ef;
29 char **items;
30 int items_num;
31 int i;
32 double t1, t2;
33
34 file = argv[1];
35 ef = eet_open(file, EET_FILE_MODE_READ);
36 if (ef)
37 {
38 items = eet_list(ef, "images/*", &items_num);
39 for (i = 0; i < items_num; i++)
40 items[i] = strdup(items[i]);
41 eet_close(ef);
42 }
43 else
44 {
45 printf("EEK. cannot load %s\n", file);
46 exit(-1);
47 }
48
49 t1 = get_time();
50 ef = eet_open(file, EET_FILE_MODE_READ);
51 if (ef)
52 {
53 for (i = 0; i < items_num; i++)
54 {
55 int w, h, alpha, compress, quality, lossy;
56 void *data;
57
58 if (eet_data_image_header_read(ef, items[i], &w, &h, &alpha, &compress, &quality, &lossy))
59 {
60 data = eet_data_image_read(ef, items[i], &w, &h, &alpha, &compress, &quality, &lossy);
61 if (data) free(data);
62 else
63 {
64 printf("failure reading %s (%i/%i\n", items[i], i, items_num);
65 exit(-1);
66 }
67 }
68 else
69 {
70 printf("failure reading header %s (%i/%i\n", items[i], i, items_num);
71 exit(-1);
72 }
73 }
74 }
75 eet_close(ef);
76 t2 = get_time();
77 printf("1 open/close: %i img headers + data in %3.3f sec (%3.3f img/sec)\n",
78 items_num,
79 t2 - t1,
80 (double)items_num / (t2 - t1));
81 t1 = get_time();
82 for (i = 0; i < items_num; i++)
83 {
84 int w, h, alpha, compress, quality, lossy;
85 void *data;
86
87 ef = eet_open(file, EET_FILE_MODE_READ);
88 if (ef)
89 {
90 if (eet_data_image_header_read(ef, items[i], &w, &h, &alpha, &compress, &quality, &lossy))
91 {
92 data = eet_data_image_read(ef, items[i], &w, &h, &alpha, &compress, &quality, &lossy);
93 if (data) free(data);
94 else
95 {
96 printf("failure reading %s (%i/%i\n", items[i], i, items_num);
97 exit(-1);
98 }
99 }
100 else
101 {
102 printf("failure reading header %s (%i/%i\n", items[i], i, items_num);
103 exit(-1);
104 }
105 eet_close(ef);
106 }
107 }
108 t2 = get_time();
109 printf("many open/close: %i img headers + data in %3.3f sec (%3.3f img/sec)\n",
110 items_num,
111 t2 - t1,
112 (double)items_num / (t2 - t1));
113 return 0;
114}