Does the exercise itself.
57{
59
60 if ( argc != 2 ) {
61 std::cerr << "usage: " << argv[0] << " <test-file>"
62 << std::endl;
63 std::exit(1);
64 }
65
66
67 double cpu_time_used = 0;
68 uint32_t events_read = 0;
69 uint32_t components_instantiated = 0;
70 RealTimeClock my_clock;
71 uint32_t event_size = 0;
72
73
74 std::fstream in(argv[1], std::ios::in|std::ios::binary);
75 if (!in) {
76 std::cerr << "File `" << argv[1] << "' does not exist?!" << std::endl;
77 std::exit(1);
78 }
79 size_t offset = 0;
80
81#ifdef PAGED_MEMORY
82 std::cout << "Working with paged storage with page size = "
84#else
85 std::cout << "Working with contiguous storage." << std::endl;
86#endif
87
88 while (in && in.good() && ! in.eof()) {
89
91 in.read((
char*)
data, 8);
92 if (!in.good() || in.eof()) break;
94
95 std::cout <<
"Word at offset " <<
HEX(offset) <<
" is not "
97 std::exit(1);
98 }
99
100#ifdef PAGED_MEMORY
101
102 in.seekg(offset);
103
104 size_t to_read =
data[1]<<2;
105 size_t page_counter = 0;
106
108 while (to_read > 0) {
110 in.read((char*)paged_event[page_counter], readnow);
111 to_read -= readnow;
112 ++page_counter;
113
114 }
115
117 for (size_t i=0; i<page_counter; ++i) {
118 myvec[i].iov_base = paged_event[i];
120 }
121
122 myvec[page_counter-1].iov_len =
data[1]<<2 - (page_counter-1)*
PAGE_SIZE;
124#else
125 in.seekg(offset);
127 in.read((
char*)event,
data[1]<<2);
128#endif
129
130 offset +=
data[1]<<2;
131
132 try {
133#ifdef PAGED_MEMORY
135 const_iterator> fe(mem.begin());
136#else
138#endif
139
140 event_size += 4*fe.fragment_size_word();
141
142 Time start = my_clock.time();
143 fe.check_tree();
144 Time end = my_clock.time();
145 Time diff = end - start;
146
147
149 components_instantiated += comps;
150
151
152
153
154
155 cpu_time_used += diff.as_milliseconds();
156 ++events_read;
157
158
159
160 }
161
163 std::cerr << std::endl
164 <<
"Uncaught eformat exception: " << ex.
what() << std::endl;
165 }
166
168 std::cerr << std::endl
169 <<
"Uncaught ERS exception: " << ex.
what() << std::endl;
170 }
171
172 catch (std::exception& ex) {
173 std::cerr << std::endl
174 << "Uncaught std exception: " << ex.what() << std::endl;
175 }
176
177 catch (...) {
178 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
179 }
180
181 }
182
183 std::cout << std::endl;
184 std::cout << " Statistics for Event Validation:" << std::endl;
185 std::cout << " --------------------------------" << std::endl;
186 std::cout << " - Total reading time: " << cpu_time_used << " millisecs"
187 << std::endl;
188 std::cout << " - Validation time per event ("
189 << events_read << "): " << cpu_time_used/events_read
190 << " millisecs" << std::endl;
191 std::cout << " - Average event size: "
192 << event_size/(1024.0*1024*events_read) << " megabytes" << std::endl;
193 std::cout << " - Validation time per component ("
194 << components_instantiated << "): "
195 << 1e3*cpu_time_used/components_instantiated
196 << " microsecs" << std::endl;
197 std::exit(0);
198}
const char * what() const
Human description message.
uint32_t components(const eformat::FullEventFragment< TPointer > &f)