40 #endif
41
42 #if TASKQUEUE_STATS
43 const char * const TaskQueueStats::_names[last_stat_id] = {
44 "qpush", "qpop", "qpop-s", "qattempt", "qsteal", "opush", "omax"
45 };
46
47 TaskQueueStats & TaskQueueStats::operator +=(const TaskQueueStats & addend)
48 {
49 for (unsigned int i = 0; i < last_stat_id; ++i) {
50 _stats[i] += addend._stats[i];
51 }
52 return *this;
53 }
54
55 void TaskQueueStats::print_header(unsigned int line, outputStream* const stream,
56 unsigned int width)
57 {
58 // Use a width w: 1 <= w <= max_width
59 const unsigned int max_width = 40;
60 const unsigned int w = MAX2(MIN2(width, max_width), 1U);
61
62 if (line == 0) { // spaces equal in width to the header
63 const unsigned int hdr_width = w * last_stat_id + last_stat_id - 1;
64 stream->print("%*s", hdr_width, " ");
65 } else if (line == 1) { // labels
66 stream->print("%*s", w, _names[0]);
67 for (unsigned int i = 1; i < last_stat_id; ++i) {
68 stream->print(" %*s", w, _names[i]);
69 }
70 } else if (line == 2) { // dashed lines
71 char dashes[max_width + 1];
72 memset(dashes, '-', w);
73 dashes[w] = '\0';
74 stream->print("%s", dashes);
75 for (unsigned int i = 1; i < last_stat_id; ++i) {
76 stream->print(" %s", dashes);
77 }
78 }
79 }
80
|
40 #endif
41
42 #if TASKQUEUE_STATS
43 const char * const TaskQueueStats::_names[last_stat_id] = {
44 "qpush", "qpop", "qpop-s", "qattempt", "qsteal", "opush", "omax"
45 };
46
47 TaskQueueStats & TaskQueueStats::operator +=(const TaskQueueStats & addend)
48 {
49 for (unsigned int i = 0; i < last_stat_id; ++i) {
50 _stats[i] += addend._stats[i];
51 }
52 return *this;
53 }
54
55 void TaskQueueStats::print_header(unsigned int line, outputStream* const stream,
56 unsigned int width)
57 {
58 // Use a width w: 1 <= w <= max_width
59 const unsigned int max_width = 40;
60 const unsigned int w = clamp(width, 1u, max_width);
61
62 if (line == 0) { // spaces equal in width to the header
63 const unsigned int hdr_width = w * last_stat_id + last_stat_id - 1;
64 stream->print("%*s", hdr_width, " ");
65 } else if (line == 1) { // labels
66 stream->print("%*s", w, _names[0]);
67 for (unsigned int i = 1; i < last_stat_id; ++i) {
68 stream->print(" %*s", w, _names[i]);
69 }
70 } else if (line == 2) { // dashed lines
71 char dashes[max_width + 1];
72 memset(dashes, '-', w);
73 dashes[w] = '\0';
74 stream->print("%s", dashes);
75 for (unsigned int i = 1; i < last_stat_id; ++i) {
76 stream->print(" %s", dashes);
77 }
78 }
79 }
80
|