text.cc (5598:345ef3bda3d2) text.cc (5599:5bad83cddb8c)
1/*
2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 225 unchanged lines hidden (view full) ---

234 Result total;
235
236 void operator()(ostream &stream) const;
237};
238
239void
240VectorPrint::operator()(std::ostream &stream) const
241{
1/*
2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 225 unchanged lines hidden (view full) ---

234 Result total;
235
236 void operator()(ostream &stream) const;
237};
238
239void
240VectorPrint::operator()(std::ostream &stream) const
241{
242 int _size = vec.size();
242 size_type _size = vec.size();
243 Result _total = 0.0;
244
245 if (flags & (pdf | cdf)) {
243 Result _total = 0.0;
244
245 if (flags & (pdf | cdf)) {
246 for (int i = 0; i < _size; ++i) {
246 for (off_type i = 0; i < _size; ++i) {
247 _total += vec[i];
248 }
249 }
250
251 string base = name + (compat ? "_" : "::");
252
253 ScalarPrint print;
254 print.name = name;

--- 6 unchanged lines hidden (view full) ---

261 print.cdf = NAN;
262
263 bool havesub = !subnames.empty();
264
265 if (_size == 1) {
266 print.value = vec[0];
267 print(stream);
268 } else if (!compat) {
247 _total += vec[i];
248 }
249 }
250
251 string base = name + (compat ? "_" : "::");
252
253 ScalarPrint print;
254 print.name = name;

--- 6 unchanged lines hidden (view full) ---

261 print.cdf = NAN;
262
263 bool havesub = !subnames.empty();
264
265 if (_size == 1) {
266 print.value = vec[0];
267 print(stream);
268 } else if (!compat) {
269 for (int i = 0; i < _size; ++i) {
269 for (off_type i = 0; i < _size; ++i) {
270 if (havesub && (i >= subnames.size() || subnames[i].empty()))
271 continue;
272
273 print.name = base + (havesub ? subnames[i] : to_string(i));
274 print.desc = subdescs.empty() ? desc : subdescs[i];
275 print.value = vec[i];
276
277 if (_total && (flags & pdf)) {

--- 15 unchanged lines hidden (view full) ---

293 print.value = total;
294 print(stream);
295 }
296
297 Result _pdf = 0.0;
298 Result _cdf = 0.0;
299 if (flags & dist) {
300 ccprintf(stream, "%s.start_dist\n", name);
270 if (havesub && (i >= subnames.size() || subnames[i].empty()))
271 continue;
272
273 print.name = base + (havesub ? subnames[i] : to_string(i));
274 print.desc = subdescs.empty() ? desc : subdescs[i];
275 print.value = vec[i];
276
277 if (_total && (flags & pdf)) {

--- 15 unchanged lines hidden (view full) ---

293 print.value = total;
294 print(stream);
295 }
296
297 Result _pdf = 0.0;
298 Result _cdf = 0.0;
299 if (flags & dist) {
300 ccprintf(stream, "%s.start_dist\n", name);
301 for (int i = 0; i < _size; ++i) {
301 for (off_type i = 0; i < _size; ++i) {
302 print.name = havesub ? subnames[i] : to_string(i);
303 print.desc = subdescs.empty() ? desc : subdescs[i];
304 print.flags |= __substat;
305 print.value = vec[i];
306
307 if (_total) {
308 _pdf = vec[i] / _total;
309 _cdf += _pdf;
310 }
311
312 if (flags & pdf)
313 print.pdf = _pdf;
314 if (flags & cdf)
315 print.cdf = _cdf;
316
317 print(stream);
318 }
319 ccprintf(stream, "%s.end_dist\n", name);
320 } else {
302 print.name = havesub ? subnames[i] : to_string(i);
303 print.desc = subdescs.empty() ? desc : subdescs[i];
304 print.flags |= __substat;
305 print.value = vec[i];
306
307 if (_total) {
308 _pdf = vec[i] / _total;
309 _cdf += _pdf;
310 }
311
312 if (flags & pdf)
313 print.pdf = _pdf;
314 if (flags & cdf)
315 print.cdf = _cdf;
316
317 print(stream);
318 }
319 ccprintf(stream, "%s.end_dist\n", name);
320 } else {
321 for (int i = 0; i < _size; ++i) {
321 for (off_type i = 0; i < _size; ++i) {
322 if (havesub && subnames[i].empty())
323 continue;
324
325 print.name = base;
326 print.name += havesub ? subnames[i] : to_string(i);
327 print.desc = subdescs.empty() ? desc : subdescs[i];
328 print.value = vec[i];
329

--- 31 unchanged lines hidden (view full) ---

361 VResult vec;
362 Result sum;
363 Result squares;
364 Result samples;
365
366 Counter min;
367 Counter max;
368 Counter bucket_size;
322 if (havesub && subnames[i].empty())
323 continue;
324
325 print.name = base;
326 print.name += havesub ? subnames[i] : to_string(i);
327 print.desc = subdescs.empty() ? desc : subdescs[i];
328 print.value = vec[i];
329

--- 31 unchanged lines hidden (view full) ---

361 VResult vec;
362 Result sum;
363 Result squares;
364 Result samples;
365
366 Counter min;
367 Counter max;
368 Counter bucket_size;
369 int size;
369 size_type size;
370 bool fancy;
371
372 void operator()(ostream &stream) const;
373};
374
375void
376DistPrint::operator()(ostream &stream) const
377{

--- 24 unchanged lines hidden (view full) ---

402 return;
403 }
404
405 assert(size == vec.size());
406
407 Result total = 0.0;
408
409 total += underflow;
370 bool fancy;
371
372 void operator()(ostream &stream) const;
373};
374
375void
376DistPrint::operator()(ostream &stream) const
377{

--- 24 unchanged lines hidden (view full) ---

402 return;
403 }
404
405 assert(size == vec.size());
406
407 Result total = 0.0;
408
409 total += underflow;
410 for (int i = 0; i < size; ++i)
410 for (off_type i = 0; i < size; ++i)
411 total += vec[i];
412 total += overflow;
413
414 string base = name + (compat ? "." : "::");
415
416 ScalarPrint print;
417 print.desc = compat ? "" : desc;
418 print.flags = flags;

--- 24 unchanged lines hidden (view full) ---

443 if (!compat && total) {
444 print.pdf = underflow / total;
445 print.cdf += print.pdf;
446 }
447 print(stream);
448 }
449
450 if (!compat) {
411 total += vec[i];
412 total += overflow;
413
414 string base = name + (compat ? "." : "::");
415
416 ScalarPrint print;
417 print.desc = compat ? "" : desc;
418 print.flags = flags;

--- 24 unchanged lines hidden (view full) ---

443 if (!compat && total) {
444 print.pdf = underflow / total;
445 print.cdf += print.pdf;
446 }
447 print(stream);
448 }
449
450 if (!compat) {
451 for (int i = 0; i < size; ++i) {
451 for (off_type i = 0; i < size; ++i) {
452 stringstream namestr;
453 namestr << name;
454
455 Counter low = i * bucket_size + min;
456 Counter high = ::min(low + bucket_size, max);
457 namestr << low;
458 if (low < high)
459 namestr << "-" << high;

--- 8 unchanged lines hidden (view full) ---

468 }
469 } else {
470 Counter _min;
471 Result _pdf;
472 Result _cdf = 0.0;
473
474 print.flags = flags | __substat;
475
452 stringstream namestr;
453 namestr << name;
454
455 Counter low = i * bucket_size + min;
456 Counter high = ::min(low + bucket_size, max);
457 namestr << low;
458 if (low < high)
459 namestr << "-" << high;

--- 8 unchanged lines hidden (view full) ---

468 }
469 } else {
470 Counter _min;
471 Result _pdf;
472 Result _cdf = 0.0;
473
474 print.flags = flags | __substat;
475
476 for (int i = 0; i < size; ++i) {
476 for (off_type i = 0; i < size; ++i) {
477 if ((flags & nozero && vec[i] == 0.0) ||
478 (flags & nonan && isnan(vec[i])))
479 continue;
480
481 _min = i * bucket_size + min;
482 _pdf = vec[i] / total * 100.0;
483 _cdf += _pdf;
484

--- 70 unchanged lines hidden (view full) ---

555}
556
557void
558Text::visit(const VectorData &data)
559{
560 if (noOutput(data))
561 return;
562
477 if ((flags & nozero && vec[i] == 0.0) ||
478 (flags & nonan && isnan(vec[i])))
479 continue;
480
481 _min = i * bucket_size + min;
482 _pdf = vec[i] / total * 100.0;
483 _cdf += _pdf;
484

--- 70 unchanged lines hidden (view full) ---

555}
556
557void
558Text::visit(const VectorData &data)
559{
560 if (noOutput(data))
561 return;
562
563 int size = data.size();
563 size_type size = data.size();
564 VectorPrint print;
565
566 print.name = data.name;
567 print.desc = data.desc;
568 print.flags = data.flags;
569 print.compat = compat;
570 print.descriptions = descriptions;
571 print.precision = data.precision;
572 print.vec = data.result();
573 print.total = data.total();
574
575 if (!data.subnames.empty()) {
564 VectorPrint print;
565
566 print.name = data.name;
567 print.desc = data.desc;
568 print.flags = data.flags;
569 print.compat = compat;
570 print.descriptions = descriptions;
571 print.precision = data.precision;
572 print.vec = data.result();
573 print.total = data.total();
574
575 if (!data.subnames.empty()) {
576 for (int i = 0; i < size; ++i) {
576 for (off_type i = 0; i < size; ++i) {
577 if (!data.subnames[i].empty()) {
578 print.subnames = data.subnames;
579 print.subnames.resize(size);
577 if (!data.subnames[i].empty()) {
578 print.subnames = data.subnames;
579 print.subnames.resize(size);
580 for (int i = 0; i < size; ++i) {
580 for (off_type i = 0; i < size; ++i) {
581 if (!data.subnames[i].empty() &&
582 !data.subdescs[i].empty()) {
583 print.subdescs = data.subdescs;
584 print.subdescs.resize(size);
585 break;
586 }
587 }
588 break;

--- 15 unchanged lines hidden (view full) ---

604
605 print.subnames = data.y_subnames;
606 print.flags = data.flags;
607 print.compat = compat;
608 print.descriptions = descriptions;
609 print.precision = data.precision;
610
611 if (!data.subnames.empty()) {
581 if (!data.subnames[i].empty() &&
582 !data.subdescs[i].empty()) {
583 print.subdescs = data.subdescs;
584 print.subdescs.resize(size);
585 break;
586 }
587 }
588 break;

--- 15 unchanged lines hidden (view full) ---

604
605 print.subnames = data.y_subnames;
606 print.flags = data.flags;
607 print.compat = compat;
608 print.descriptions = descriptions;
609 print.precision = data.precision;
610
611 if (!data.subnames.empty()) {
612 for (int i = 0; i < data.x; ++i)
612 for (off_type i = 0; i < data.x; ++i)
613 if (!data.subnames[i].empty())
614 havesub = true;
615 }
616
617 VResult tot_vec(data.y);
618 Result super_total = 0.0;
613 if (!data.subnames[i].empty())
614 havesub = true;
615 }
616
617 VResult tot_vec(data.y);
618 Result super_total = 0.0;
619 for (int i = 0; i < data.x; ++i) {
619 for (off_type i = 0; i < data.x; ++i) {
620 if (havesub && (i >= data.subnames.size() || data.subnames[i].empty()))
621 continue;
622
620 if (havesub && (i >= data.subnames.size() || data.subnames[i].empty()))
621 continue;
622
623 int iy = i * data.y;
623 off_type iy = i * data.y;
624 VResult yvec(data.y);
625
626 Result total = 0.0;
624 VResult yvec(data.y);
625
626 Result total = 0.0;
627 for (int j = 0; j < data.y; ++j) {
627 for (off_type j = 0; j < data.y; ++j) {
628 yvec[j] = data.cvec[iy + j];
629 tot_vec[j] += yvec[j];
630 total += yvec[j];
631 super_total += yvec[j];
632 }
633
634 print.name = data.name + "_" +
635 (havesub ? data.subnames[i] : to_string(i));

--- 27 unchanged lines hidden (view full) ---

663 print.descriptions = descriptions;
664 print.precision = data.precision;
665
666 print.min_val = data.data.min_val;
667 print.max_val = data.data.max_val;
668 print.underflow = data.data.underflow;
669 print.overflow = data.data.overflow;
670 print.vec.resize(data.data.cvec.size());
628 yvec[j] = data.cvec[iy + j];
629 tot_vec[j] += yvec[j];
630 total += yvec[j];
631 super_total += yvec[j];
632 }
633
634 print.name = data.name + "_" +
635 (havesub ? data.subnames[i] : to_string(i));

--- 27 unchanged lines hidden (view full) ---

663 print.descriptions = descriptions;
664 print.precision = data.precision;
665
666 print.min_val = data.data.min_val;
667 print.max_val = data.data.max_val;
668 print.underflow = data.data.underflow;
669 print.overflow = data.data.overflow;
670 print.vec.resize(data.data.cvec.size());
671 for (int i = 0; i < print.vec.size(); ++i)
671 for (off_type i = 0; i < print.vec.size(); ++i)
672 print.vec[i] = (Result)data.data.cvec[i];
673 print.sum = data.data.sum;
674 print.squares = data.data.squares;
675 print.samples = data.data.samples;
676
677 print.min = data.data.min;
678 print.max = data.data.max;
679 print.bucket_size = data.data.bucket_size;

--- 4 unchanged lines hidden (view full) ---

684}
685
686void
687Text::visit(const VectorDistData &data)
688{
689 if (noOutput(data))
690 return;
691
672 print.vec[i] = (Result)data.data.cvec[i];
673 print.sum = data.data.sum;
674 print.squares = data.data.squares;
675 print.samples = data.data.samples;
676
677 print.min = data.data.min;
678 print.max = data.data.max;
679 print.bucket_size = data.data.bucket_size;

--- 4 unchanged lines hidden (view full) ---

684}
685
686void
687Text::visit(const VectorDistData &data)
688{
689 if (noOutput(data))
690 return;
691
692 for (int i = 0; i < data.size(); ++i) {
692 for (off_type i = 0; i < data.size(); ++i) {
693 DistPrint print;
694
695 print.name = data.name + "_" +
696 (data.subnames[i].empty() ? (to_string(i)) : data.subnames[i]);
697 print.desc = data.subdescs[i].empty() ? data.desc : data.subdescs[i];
698 print.flags = data.flags;
699 print.compat = compat;
700 print.descriptions = descriptions;
701 print.precision = data.precision;
702
703 print.min_val = data.data[i].min_val;
704 print.max_val = data.data[i].max_val;
705 print.underflow = data.data[i].underflow;
706 print.overflow = data.data[i].overflow;
707 print.vec.resize(data.data[i].cvec.size());
693 DistPrint print;
694
695 print.name = data.name + "_" +
696 (data.subnames[i].empty() ? (to_string(i)) : data.subnames[i]);
697 print.desc = data.subdescs[i].empty() ? data.desc : data.subdescs[i];
698 print.flags = data.flags;
699 print.compat = compat;
700 print.descriptions = descriptions;
701 print.precision = data.precision;
702
703 print.min_val = data.data[i].min_val;
704 print.max_val = data.data[i].max_val;
705 print.underflow = data.data[i].underflow;
706 print.overflow = data.data[i].overflow;
707 print.vec.resize(data.data[i].cvec.size());
708 for (int j = 0; j < print.vec.size(); ++j)
708 for (off_type j = 0; j < print.vec.size(); ++j)
709 print.vec[j] = (Result)data.data[i].cvec[j];
710 print.sum = data.data[i].sum;
711 print.squares = data.data[i].squares;
712 print.samples = data.data[i].samples;
713
714 print.min = data.data[i].min;
715 print.max = data.data[i].max;
716 print.bucket_size = data.data[i].bucket_size;

--- 34 unchanged lines hidden ---
709 print.vec[j] = (Result)data.data[i].cvec[j];
710 print.sum = data.data[i].sum;
711 print.squares = data.data[i].squares;
712 print.samples = data.data[i].samples;
713
714 print.min = data.data[i].min;
715 print.max = data.data[i].max;
716 print.bucket_size = data.data[i].bucket_size;

--- 34 unchanged lines hidden ---