23 #include <HDDM/hddm_r.hpp>
38 std::map<int, hddm_r::streamposition>
postable;
41 int tid = *((
int**)arg)[0];
42 hddm_r::istream &fin = *((hddm_r::istream**)arg)[1];
45 int evno = rec.getReconstructedPhysicsEvent().getEventNo();
46 if (evno > 0 && evno % 10000 == 0)
47 printf(
" event %d %d\n", evno, tid);
48 pthread_mutex_lock(&
lock);
49 postable[evno] = fin.getPosition();
50 pthread_mutex_unlock(&
lock);
56 int tid = *((
int**)arg)[0];
57 hddm_r::istream &fin = *((hddm_r::istream**)arg)[1];
58 hddm_r::ostream &fout = *((hddm_r::ostream**)arg)[2];
61 int evno = rec.getReconstructedPhysicsEvent().getEventNo();
62 if (evno > 0 && evno % 10000 == 0)
63 printf(
" event %d %d\n", evno, tid);
70 int tid = *((
int**)arg)[0];
71 hddm_r::istream &fin = *((hddm_r::istream**)arg)[1];
72 std::map<int, hddm_r::streamposition> &post =
73 *((std::map<int, hddm_r::streamposition>**)arg)[2];
74 std::map<int, hddm_r::streamposition>::iterator iter;
75 for (iter = post.begin(); iter != post.end(); ++iter) {
76 fin.setPosition(iter->second);
79 if (iter->first != rec.getReconstructedPhysicsEvent().getEventNo()) {
80 pthread_mutex_lock(&
lock);
81 printf(
"bad event lookup for event %d in thread %d: ", iter->first, tid);
82 printf(
"requested %d but got %ld\n", iter->first,
83 rec.getReconstructedPhysicsEvent().getEventNo());
84 printf(
"requested (%ld,%d,%d) and got (%ld,%d,%d)\n",
85 post[iter->first].block_start,
86 post[iter->first].block_offset,
87 post[iter->first].block_status,
88 fin.getPosition().block_start,
89 fin.getPosition().block_offset,
90 fin.getPosition().block_status);
91 pthread_mutex_unlock(&
lock);
94 else if (fin.getPosition() != post[iter->first]) {
95 pthread_mutex_lock(&
lock);
96 printf(
"bad record position for event %d: ", iter->first);
97 printf(
"requested (%ld,%d,%d) but got (%ld,%d,%d)\n",
98 post[iter->first].block_start,
99 post[iter->first].block_offset,
100 post[iter->first].block_status,
101 fin.getPosition().block_start,
102 fin.getPosition().block_offset,
103 fin.getPosition().block_status);
104 pthread_mutex_unlock(&
lock);
107 else if (iter->first > 0 && iter->first % 10000 == 0) {
108 printf(
" event %d\n", iter->first);
116 printf(
"usage: t_rest [options] <input_hddm_file>\n"
117 " where options may include any of the following:\n"
118 " -n <count> : stop after reading <count> events from the\n"
119 " input hddm file, default is the entire file\n"
120 " -p <count> : use <count> i/o threads in multi-thread tests,\n"
122 " -h, --help : display this help message\n"
127 int main(
int argc,
const char *argv[])
130 for (narg=1; narg < argc; ++narg) {
131 if (strncmp(argv[narg],
"-n", 2) == 0) {
134 else if (strncmp(argv[narg],
"--Nevents", 9) == 0) {
137 else if (strncmp(argv[narg],
"-p", 2) == 0) {
140 else if (strncmp(argv[narg],
"-Nthreads", 9) == 0) {
143 else if (strncmp(argv[narg],
"-h", 2) == 0) {
146 else if (strncmp(argv[narg],
"-?", 2) == 0) {
149 else if (strncmp(argv[narg],
"--help", 6) == 0) {
164 std::map<int, hddm_r::streamposition> postable_bz2;
165 std::map<int, hddm_r::streamposition> postable_z;
166 std::map<int, hddm_r::streamposition> postable_none;
168 pthread_mutex_init(&
lock, 0);
170 printf(
"test 0: copying records from input file\n");
173 std::ifstream ifs(argv[narg]);
174 hddm_r::istream fin(ifs);
175 std::ofstream ofs0(rest_none.c_str());
176 std::ofstream ofs1(rest_z.c_str());
177 std::ofstream ofs2(rest_bz2.c_str());
178 hddm_r::ostream fout0(ofs0);
179 hddm_r::ostream fout1(ofs1);
180 fout1.setCompression(hddm_r::k_z_compression);
181 hddm_r::ostream fout2(ofs2);
182 fout2.setCompression(hddm_r::k_bz2_compression);
185 int evno = rec.getReconstructedPhysicsEvent().getEventNo();
186 if (evno > 0 && evno % 10000 == 0)
187 printf(
" event %d\n", evno);
196 printf(
"test 1: reading single-threaded from input file, bz2 compression\n");
199 std::ifstream ifs(rest_bz2);
200 hddm_r::istream fin(ifs);
202 clock_gettime(CLOCK_REALTIME, &t0);
205 int evno = rec.getReconstructedPhysicsEvent().getEventNo();
206 if (evno > 0 && evno % 10000 == 0)
207 printf(
" event %d\n", evno);
208 postable_bz2[evno] = fin.getPosition();
211 clock_gettime(CLOCK_REALTIME, &t1);
212 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
213 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
214 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
215 fin.getBytesRead() / tlapse / 1e6);
218 printf(
"test 2: reading single-threaded from input file, zlib compression\n");
221 std::ifstream ifs(rest_z);
222 hddm_r::istream fin(ifs);
224 clock_gettime(CLOCK_REALTIME, &t0);
227 int evno = rec.getReconstructedPhysicsEvent().getEventNo();
228 if (evno > 0 && evno % 10000 == 0)
229 printf(
" event %d\n", evno);
230 postable_z[evno] = fin.getPosition();
233 clock_gettime(CLOCK_REALTIME, &t1);
234 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
235 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
236 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
237 fin.getBytesRead() / tlapse / 1e6);
240 printf(
"test 3: reading single-threaded from input file, no compression\n");
243 std::ifstream ifs(rest_none);
244 hddm_r::istream fin(ifs);
246 clock_gettime(CLOCK_REALTIME, &t0);
249 int evno = rec.getReconstructedPhysicsEvent().getEventNo();
250 if (evno > 0 && evno % 10000 == 0)
251 printf(
" event %d\n", evno);
252 postable_none[evno] = fin.getPosition();
255 clock_gettime(CLOCK_REALTIME, &t1);
256 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
257 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
258 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
259 fin.getBytesRead() / tlapse / 1e6);
263 printf(
"test 4: writing single-threaded to output file, bz2 compression\n");
266 std::ifstream ifs(rest_none);
267 hddm_r::istream fin(ifs);
268 std::ofstream ofs(
"." + rest_bz2);
269 hddm_r::ostream fout(ofs);
270 fout.setCompression(hddm_r::k_bz2_compression);
272 clock_gettime(CLOCK_REALTIME, &t0);
275 int evno = rec.getReconstructedPhysicsEvent().getEventNo();
276 if (evno > 0 && evno % 10000 == 0)
277 printf(
" event %d\n", evno);
281 clock_gettime(CLOCK_REALTIME, &t1);
282 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
284 printf(
" %d events written in %f seconds,", fout.getRecordsWritten(), tlapse);
285 printf(
" %f ev/s, %f MB/s\n", fout.getRecordsWritten() / tlapse,
286 fout.getBytesWritten() / tlapse / 1e6);
289 printf(
"test 5: writing single-threaded to output file, zlib compression\n");
292 std::ifstream ifs(rest_none);
293 hddm_r::istream fin(ifs);
294 std::ofstream ofs(
"." + rest_z);
295 hddm_r::ostream fout(ofs);
296 fout.setCompression(hddm_r::k_z_compression);
298 clock_gettime(CLOCK_REALTIME, &t0);
301 int evno = rec.getReconstructedPhysicsEvent().getEventNo();
302 if (evno > 0 && evno % 10000 == 0)
303 printf(
" event %d\n", evno);
307 clock_gettime(CLOCK_REALTIME, &t1);
308 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
310 printf(
" %d events written in %f seconds,", fout.getRecordsWritten(), tlapse);
311 printf(
" %f ev/s, %f MB/s\n", fout.getRecordsWritten() / tlapse,
312 fout.getBytesWritten() / tlapse / 1e6);
315 printf(
"test 6: writing single-threaded to output file, no compression\n");
318 std::ifstream ifs(rest_none);
319 hddm_r::istream fin(ifs);
320 std::ofstream ofs(
"." + rest_none);
321 hddm_r::ostream fout(ofs);
323 clock_gettime(CLOCK_REALTIME, &t0);
326 int evno = rec.getReconstructedPhysicsEvent().getEventNo();
327 if (evno > 0 && evno % 10000 == 0)
328 printf(
" event %d\n", evno);
332 clock_gettime(CLOCK_REALTIME, &t1);
333 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
335 printf(
" %d events written in %f seconds,", fout.getRecordsWritten(), tlapse);
336 printf(
" %f ev/s, %f MB/s\n", fout.getRecordsWritten() / tlapse,
337 fout.getBytesWritten() / tlapse / 1e6);
340 printf(
"test 7: reading multi-threaded from input file, bz2 compression\n");
343 std::ifstream ifs(
"." + rest_bz2);
344 hddm_r::istream fin(ifs);
346 std::list<pthread_t*> threads;
348 clock_gettime(CLOCK_REALTIME, &t0);
350 pthread_t *thread =
new pthread_t;
351 void *args[2] = {&tid, &fin};
353 threads.push_back(thread);
355 std::list<pthread_t*>::iterator iter;
356 for (iter = threads.begin(); iter != threads.end(); ++iter) {
358 pthread_join(**iter, &retval);
362 clock_gettime(CLOCK_REALTIME, &t1);
363 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
364 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
365 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
366 fin.getBytesRead() / tlapse / 1e6);
368 std::map<int, hddm_r::streamposition> postable_dot_bz2(postable);
370 printf(
"test 8: reading multi-threaded from input file, zlib compression\n");
373 std::ifstream ifs(
"." + rest_z);
374 hddm_r::istream fin(ifs);
376 std::list<pthread_t*> threads;
378 clock_gettime(CLOCK_REALTIME, &t0);
380 pthread_t *thread =
new pthread_t;
381 void *args[2] = {&tid, &fin};
383 threads.push_back(thread);
385 std::list<pthread_t*>::iterator iter;
386 for (iter = threads.begin(); iter != threads.end(); ++iter) {
388 pthread_join(**iter, &retval);
392 clock_gettime(CLOCK_REALTIME, &t1);
393 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
394 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
395 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
396 fin.getBytesRead() / tlapse / 1e6);
398 std::map<int, hddm_r::streamposition> postable_dot_z(postable);
400 printf(
"test 9: reading multi-threaded from input file, no compression\n");
403 std::ifstream ifs(
"." + rest_none);
404 hddm_r::istream fin(ifs);
406 std::list<pthread_t*> threads;
408 clock_gettime(CLOCK_REALTIME, &t0);
410 pthread_t *thread =
new pthread_t;
411 void *args[2] = {&tid, &fin};
413 threads.push_back(thread);
415 std::list<pthread_t*>::iterator iter;
416 for (iter = threads.begin(); iter != threads.end(); ++iter) {
418 pthread_join(**iter, &retval);
422 clock_gettime(CLOCK_REALTIME, &t1);
423 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
424 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
425 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
426 fin.getBytesRead() / tlapse / 1e6);
428 std::map<int, hddm_r::streamposition> postable_dot_none(postable);
430 printf(
"test 10: writing multi-threaded to output file, bz2 compression\n");
433 std::ifstream ifs(rest_none);
434 hddm_r::istream fin(ifs);
435 std::ofstream ofs(
".." + rest_bz2);
436 hddm_r::ostream fout(ofs);
437 fout.setCompression(hddm_r::k_bz2_compression);
438 std::list<pthread_t*> threads;
440 clock_gettime(CLOCK_REALTIME, &t0);
442 pthread_t *thread =
new pthread_t;
443 void *args[3] = {&tid, &fin, &fout};
445 threads.push_back(thread);
447 std::list<pthread_t*>::iterator iter;
448 for (iter = threads.begin(); iter != threads.end(); ++iter) {
450 pthread_join(**iter, &retval);
454 clock_gettime(CLOCK_REALTIME, &t1);
455 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
457 printf(
" %d events written in %f seconds,", fout.getRecordsWritten(), tlapse);
458 printf(
" %f ev/s, %f MB/s\n", fout.getRecordsWritten() / tlapse,
459 fout.getBytesWritten() / tlapse / 1e6);
462 printf(
"test 11: writing multi-threaded to output file, zlib compression\n");
465 std::ifstream ifs(rest_none);
466 hddm_r::istream fin(ifs);
467 std::ofstream ofs(
".." + rest_z);
468 hddm_r::ostream fout(ofs);
469 fout.setCompression(hddm_r::k_z_compression);
470 std::list<pthread_t*> threads;
472 clock_gettime(CLOCK_REALTIME, &t0);
474 pthread_t *thread =
new pthread_t;
475 void *args[3] = {&tid, &fin, &fout};
477 threads.push_back(thread);
479 std::list<pthread_t*>::iterator iter;
480 for (iter = threads.begin(); iter != threads.end(); ++iter) {
482 pthread_join(**iter, &retval);
486 clock_gettime(CLOCK_REALTIME, &t1);
487 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
489 printf(
" %d events written in %f seconds,", fout.getRecordsWritten(), tlapse);
490 printf(
" %f ev/s, %f MB/s\n", fout.getRecordsWritten() / tlapse,
491 fout.getBytesWritten() / tlapse / 1e6);
494 printf(
"test 12: writing multi-threaded to output file, no compression\n");
497 std::ifstream ifs(rest_none);
498 hddm_r::istream fin(ifs);
499 std::ofstream ofs(
".." + rest_none);
500 hddm_r::ostream fout(ofs);
501 std::list<pthread_t*> threads;
503 clock_gettime(CLOCK_REALTIME, &t0);
505 pthread_t *thread =
new pthread_t;
506 void *args[3] = {&tid, &fin, &fout};
508 threads.push_back(thread);
510 std::list<pthread_t*>::iterator iter;
511 for (iter = threads.begin(); iter != threads.end(); ++iter) {
513 pthread_join(**iter, &retval);
517 clock_gettime(CLOCK_REALTIME, &t1);
518 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
520 printf(
" %d events written in %f seconds,", fout.getRecordsWritten(), tlapse);
521 printf(
" %f ev/s, %f MB/s\n", fout.getRecordsWritten() / tlapse,
522 fout.getBytesWritten() / tlapse / 1e6);
525 printf(
"test 13: reading from multi-threaded output file, bz2 compression\n");
528 std::ifstream ifs(
".." + rest_bz2);
529 hddm_r::istream fin(ifs);
531 std::list<pthread_t*> threads;
533 clock_gettime(CLOCK_REALTIME, &t0);
535 pthread_t *thread =
new pthread_t;
536 void *args[2] = {&tid, &fin};
538 threads.push_back(thread);
540 std::list<pthread_t*>::iterator iter;
541 for (iter = threads.begin(); iter != threads.end(); ++iter) {
543 pthread_join(**iter, &retval);
547 clock_gettime(CLOCK_REALTIME, &t1);
548 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
549 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
550 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
551 fin.getBytesRead() / tlapse / 1e6);
553 std::map<int, hddm_r::streamposition> postable_dotdot_bz2(postable);
555 printf(
"test 14: reading from multi-threaded output file, zlib compression\n");
558 std::ifstream ifs(
".." + rest_z);
559 hddm_r::istream fin(ifs);
561 std::list<pthread_t*> threads;
563 clock_gettime(CLOCK_REALTIME, &t0);
565 pthread_t *thread =
new pthread_t;
566 void *args[2] = {&tid, &fin};
568 threads.push_back(thread);
570 std::list<pthread_t*>::iterator iter;
571 for (iter = threads.begin(); iter != threads.end(); ++iter) {
573 pthread_join(**iter, &retval);
577 clock_gettime(CLOCK_REALTIME, &t1);
578 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
579 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
580 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
581 fin.getBytesRead() / tlapse / 1e6);
583 std::map<int, hddm_r::streamposition> postable_dotdot_z(postable);
585 printf(
"test 15: reading from multi-threaded output file, no compression\n");
588 std::ifstream ifs(
".." + rest_none);
589 hddm_r::istream fin(ifs);
591 std::list<pthread_t*> threads;
593 clock_gettime(CLOCK_REALTIME, &t0);
595 pthread_t *thread =
new pthread_t;
596 void *args[2] = {&tid, &fin};
598 threads.push_back(thread);
600 std::list<pthread_t*>::iterator iter;
601 for (iter = threads.begin(); iter != threads.end(); ++iter) {
603 pthread_join(**iter, &retval);
607 clock_gettime(CLOCK_REALTIME, &t1);
608 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
609 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
610 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
611 fin.getBytesRead() / tlapse / 1e6);
613 std::map<int, hddm_r::streamposition> postable_dotdot_none(postable);
615 printf(
"test 16: single-threaded random access reads, bz2 compression\n");
618 std::ifstream ifs(rest_bz2);
619 hddm_r::istream fin(ifs);
621 clock_gettime(CLOCK_REALTIME, &t0);
622 std::map<int, hddm_r::streamposition>::iterator iter;
623 for (iter = postable_bz2.begin(); iter != postable_bz2.end(); ++iter) {
624 fin.setPosition(iter->second);
627 if (iter->first != rec.getReconstructedPhysicsEvent().getEventNo()) {
628 printf(
"bad event lookup for event %d in file %s: ",
629 iter->first, rest_bz2.c_str());
630 printf(
"requested %d but got %ld\n", iter->first,
631 rec.getReconstructedPhysicsEvent().getEventNo());
632 printf(
"requested (%ld,%d,%d) and got (%ld,%d,%d)\n",
633 iter->second.block_start,
634 iter->second.block_offset,
635 iter->second.block_status,
636 fin.getPosition().block_start,
637 fin.getPosition().block_offset,
638 fin.getPosition().block_status);
641 else if (fin.getPosition() != iter->second) {
642 printf(
"bad record position for event %d in file %s: ",
643 iter->first, rest_bz2.c_str());
644 printf(
"requested (%ld,%d,%d) but got (%ld,%d,%d)\n",
645 iter->second.block_start,
646 iter->second.block_offset,
647 iter->second.block_status,
648 fin.getPosition().block_start,
649 fin.getPosition().block_offset,
650 fin.getPosition().block_status);
653 else if (iter->first > 0 && iter->first % 1000 == 0 ) {
654 printf(
" event %d\n", iter->first);
658 clock_gettime(CLOCK_REALTIME, &t1);
659 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
660 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
661 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
662 fin.getBytesRead() / tlapse / 1e6);
665 printf(
"test 17: single-threaded random access reads, z compression\n");
668 std::ifstream ifs(rest_z);
669 hddm_r::istream fin(ifs);
671 clock_gettime(CLOCK_REALTIME, &t0);
672 std::map<int, hddm_r::streamposition>::iterator iter;
673 for (iter = postable_z.begin(); iter != postable_z.end(); ++iter) {
674 fin.setPosition(iter->second);
677 if (iter->first != rec.getReconstructedPhysicsEvent().getEventNo()) {
678 printf(
"bad event lookup for event %d in file %s: ",
679 iter->first, rest_z.c_str());
680 printf(
"requested %d but got %ld\n", iter->first,
681 rec.getReconstructedPhysicsEvent().getEventNo());
682 printf(
"requested (%ld,%d,%d) and got (%ld,%d,%d)\n",
683 iter->second.block_start,
684 iter->second.block_offset,
685 iter->second.block_status,
686 fin.getPosition().block_start,
687 fin.getPosition().block_offset,
688 fin.getPosition().block_status);
691 else if (fin.getPosition() != iter->second) {
692 printf(
"bad record position for event %d in file %s: ",
693 iter->first, rest_z.c_str());
694 printf(
"requested (%ld,%d,%d) but got (%ld,%d,%d)\n",
695 iter->second.block_start,
696 iter->second.block_offset,
697 iter->second.block_status,
698 fin.getPosition().block_start,
699 fin.getPosition().block_offset,
700 fin.getPosition().block_status);
703 else if (iter->first > 0 && iter->first % 1000 == 0 ) {
704 printf(
" event %d\n", iter->first);
708 clock_gettime(CLOCK_REALTIME, &t1);
709 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
710 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
711 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
712 fin.getBytesRead() / tlapse / 1e6);
715 printf(
"test 18: single-threaded random access reads, no compression\n");
718 std::ifstream ifs(rest_none);
719 hddm_r::istream fin(ifs);
721 clock_gettime(CLOCK_REALTIME, &t0);
722 std::map<int, hddm_r::streamposition>::iterator iter;
723 for (iter = postable_none.begin(); iter != postable_none.end(); ++iter) {
724 fin.setPosition(iter->second);
727 if (iter->first != rec.getReconstructedPhysicsEvent().getEventNo()) {
728 printf(
"bad event lookup for event %d in file %s: ",
729 iter->first, rest_none.c_str());
730 printf(
"requested %d but got %ld\n", iter->first,
731 rec.getReconstructedPhysicsEvent().getEventNo());
732 printf(
"requested (%ld,%d,%d) and got (%ld,%d,%d)\n",
733 iter->second.block_start,
734 iter->second.block_offset,
735 iter->second.block_status,
736 fin.getPosition().block_start,
737 fin.getPosition().block_offset,
738 fin.getPosition().block_status);
741 else if (fin.getPosition() != iter->second) {
742 printf(
"bad record position for event %d in file %s: ",
743 iter->first, rest_none.c_str());
744 printf(
"requested (%ld,%d,%d) but got (%ld,%d,%d)\n",
745 iter->second.block_start,
746 iter->second.block_offset,
747 iter->second.block_status,
748 fin.getPosition().block_start,
749 fin.getPosition().block_offset,
750 fin.getPosition().block_status);
753 else if (iter->first > 0 && iter->first % 1000 == 0 ) {
754 printf(
" event %d\n", iter->first);
758 clock_gettime(CLOCK_REALTIME, &t1);
759 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
760 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
761 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
762 fin.getBytesRead() / tlapse / 1e6);
765 printf(
"test 19: multi-threaded random access reads, bz2 compression\n");
768 std::ifstream ifs(rest_bz2);
769 hddm_r::istream fin(ifs);
770 std::list<pthread_t*> threads;
772 clock_gettime(CLOCK_REALTIME, &t0);
774 pthread_t *thread =
new pthread_t;
775 void *args[3] = {&tid, &fin, &postable_bz2};
777 threads.push_back(thread);
779 std::list<pthread_t*>::iterator iter;
780 for (iter = threads.begin(); iter != threads.end(); ++iter) {
782 pthread_join(**iter, &retval);
786 clock_gettime(CLOCK_REALTIME, &t1);
787 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
788 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
789 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
790 fin.getBytesRead() / tlapse / 1e6);
793 printf(
"test 20: multi-threaded random access reads, z compression\n");
796 std::ifstream ifs(rest_z);
797 hddm_r::istream fin(ifs);
798 std::list<pthread_t*> threads;
800 clock_gettime(CLOCK_REALTIME, &t0);
802 pthread_t *thread =
new pthread_t;
803 void *args[3] = {&tid, &fin, &postable_z};
805 threads.push_back(thread);
807 std::list<pthread_t*>::iterator iter;
808 for (iter = threads.begin(); iter != threads.end(); ++iter) {
810 pthread_join(**iter, &retval);
814 clock_gettime(CLOCK_REALTIME, &t1);
815 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
816 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
817 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
818 fin.getBytesRead() / tlapse / 1e6);
821 printf(
"test 21: multi-threaded random access reads, no compression\n");
824 std::ifstream ifs(rest_none);
825 hddm_r::istream fin(ifs);
826 std::list<pthread_t*> threads;
828 clock_gettime(CLOCK_REALTIME, &t0);
830 pthread_t *thread =
new pthread_t;
831 void *args[3] = {&tid, &fin, &postable_none};
833 threads.push_back(thread);
835 std::list<pthread_t*>::iterator iter;
836 for (iter = threads.begin(); iter != threads.end(); ++iter) {
838 pthread_join(**iter, &retval);
842 clock_gettime(CLOCK_REALTIME, &t1);
843 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
844 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
845 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
846 fin.getBytesRead() / tlapse / 1e6);
849 printf(
"test 22: multi-threaded random access reads, mt-bz2 compression\n");
852 std::ifstream ifs(
".." + rest_bz2);
853 hddm_r::istream fin(ifs);
854 std::list<pthread_t*> threads;
856 clock_gettime(CLOCK_REALTIME, &t0);
858 pthread_t *thread =
new pthread_t;
859 void *args[3] = {&tid, &fin, &postable_dotdot_bz2};
861 threads.push_back(thread);
863 std::list<pthread_t*>::iterator iter;
864 for (iter = threads.begin(); iter != threads.end(); ++iter) {
866 pthread_join(**iter, &retval);
870 clock_gettime(CLOCK_REALTIME, &t1);
871 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
872 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
873 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
874 fin.getBytesRead() / tlapse / 1e6);
877 printf(
"test 23: multi-threaded random access reads, mt-z compression\n");
880 std::ifstream ifs(
".." + rest_z);
881 hddm_r::istream fin(ifs);
882 std::list<pthread_t*> threads;
884 clock_gettime(CLOCK_REALTIME, &t0);
886 pthread_t *thread =
new pthread_t;
887 void *args[3] = {&tid, &fin, &postable_dotdot_z};
889 threads.push_back(thread);
891 std::list<pthread_t*>::iterator iter;
892 for (iter = threads.begin(); iter != threads.end(); ++iter) {
894 pthread_join(**iter, &retval);
898 clock_gettime(CLOCK_REALTIME, &t1);
899 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
900 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
901 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
902 fin.getBytesRead() / tlapse / 1e6);
905 printf(
"test 24: multi-threaded random access reads, mt-no compression\n");
908 std::ifstream ifs(
".." + rest_none);
909 hddm_r::istream fin(ifs);
910 std::list<pthread_t*> threads;
912 clock_gettime(CLOCK_REALTIME, &t0);
914 pthread_t *thread =
new pthread_t;
915 void *args[3] = {&tid, &fin, &postable_dotdot_none};
917 threads.push_back(thread);
919 std::list<pthread_t*>::iterator iter;
920 for (iter = threads.begin(); iter != threads.end(); ++iter) {
922 pthread_join(**iter, &retval);
926 clock_gettime(CLOCK_REALTIME, &t1);
927 float tlapse = (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec)*1
e-9;
928 printf(
" %d events read in %f seconds,", fin.getRecordsRead(), tlapse);
929 printf(
" %f ev/s, %f MB/s\n", fin.getRecordsRead() / tlapse,
930 fin.getBytesRead() / tlapse / 1e6);
void * event_reader(void *arg)
void * random_reader(void *arg)
void * event_writer(void *arg)
std::map< int, hddm_r::streamposition > postable
printf("string=%s", string)
int main(int argc, char *argv[])