30int main(
int argc,
char** argv ) {
35 std::cerr <<
"usage: " << argv[0] <<
" <test-file>" << std::endl;
40 double cpu_time_used = 0;
41 uint32_t elements_read = 0;
42 uint32_t robs_read = 0;
43 RealTimeClock my_clock;
46 std::fstream in( argv[1], std::ios::in | std::ios::binary );
49 std::cerr <<
"File `" << argv[1] <<
"' does not exist?!" << std::endl;
55 std::cout <<
"Working with paged storage with page size = " <<
PAGE_SIZE <<
" bytes."
58 std::cout <<
"Working with contiguous storage." << std::endl;
61 while ( in && in.good() && !in.eof() )
65 in.read( (
char*)
data, 8 );
66 if ( !in.good() || in.eof() )
break;
70 std::cout <<
"Word at offset " <<
HEX( offset ) <<
" is not "
79 size_t to_read =
data[1] << 2;
80 size_t page_counter = 0;
86 in.read( (
char*)paged_event[page_counter], readnow );
93 for (
size_t i = 0; i < page_counter; ++i )
95 myvec[i].iov_base = paged_event[i];
99 myvec[page_counter - 1].iov_len =
data[1] << 2 - ( page_counter - 1 ) *
PAGE_SIZE;
104 in.read( (
char*)event,
data[1] << 2 );
107 offset +=
data[1] << 2;
117 typedef const uint32_t* pointer_t;
120 std::vector<pointer_t> robs;
123 uint32_t nsd = fe.children( sdp, 64 );
124 for (
size_t i = 0; i < nsd; ++i )
129 uint32_t nros = sd.
children( rosp, 256 );
130 for (
size_t j = 0; j < nros; ++j )
134 pointer_t robp[2048];
135 uint32_t nrob = ros.
children( robp, 2048 );
136 robs.insert( robs.end(), robp, &robp[nrob] );
140 uint32_t global_counter = 0;
141 Time start = my_clock.time();
142 for ( std::vector<pointer_t>::const_iterator it = robs.begin(); it != robs.end(); ++it )
148 for (
size_t m = 0; m < ndata; ++m )
150 global_counter += my[m];
155 Time end = my_clock.time();
156 Time diff = end - start;
157 cpu_time_used += diff.as_milliseconds();
162 std::cerr << std::endl <<
"Uncaught eformat exception: " << ex.
what() << std::endl;
167 std::cerr << std::endl <<
"Uncaught ERS exception: " << ex.
what() << std::endl;
170 catch ( std::exception& ex )
172 std::cerr << std::endl <<
"Uncaught std exception: " << ex.
what() << std::endl;
176 { std::cerr << std::endl <<
"Uncaught unknown exception" << std::endl; }
179 std::cout <<
" Statistics for ROB data access:" << std::endl;
180 std::cout <<
" -------------------------------" << std::endl;
181 std::cout <<
" - Total reading time: " << cpu_time_used <<
" millisecs" << std::endl;
182 std::cout <<
" - Reading time per ROB (" << robs_read
183 <<
"): " << 1e3 * cpu_time_used / robs_read <<
" microsecs" << std::endl;
184 std::cout <<
" - Reading time per data word in a ROB (" << elements_read
185 <<
"): " << 1e6 * cpu_time_used / elements_read <<
" nanosecs" << std::endl;