MCPcopy Create free account
hub / github.com/davisking/dlib / print

Function print

dlib/timing.h:122–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120 }
121
122 inline void print()
123 {
124 std::cout << "Timing report: " << std::endl;
125
126 // figure out how long the longest name is going to be.
127 unsigned long max_name_length = 0;
128 for (int i = 0; i < TIME_SLOTS; ++i)
129 {
130 std::string name;
131 // Check if the name buffer is empty. Use the name it contains if it isn't.
132 if (name_buf(i,"")[0] != '\0')
133 name = cast_to_string(i) + ": " + name_buf(i,"");
134 else
135 name = cast_to_string(i);
136 max_name_length = std::max<unsigned long>(max_name_length, name.size());
137 }
138
139 for (int i = 0; i < TIME_SLOTS; ++i)
140 {
141 if (time_buf()[i] != 0)
142 {
143 double time = time_buf()[i]/1000.0/1000.0;
144 std::string name;
145 // Check if the name buffer is empty. Use the name it contains if it isn't.
146 if (name_buf(i,"")[0] != '\0')
147 name = cast_to_string(i) + ": " + name_buf(i,"");
148 else
149 name = cast_to_string(i);
150
151 // make sure the name is always the same length. Do so by padding with spaces
152 if (name.size() < max_name_length)
153 name += std::string(max_name_length-name.size(),' ');
154
155 if (time < 1000)
156 std::cout << " " << name << ": " << time << " milliseconds" << std::endl;
157 else if (time < 1000*60)
158 std::cout << " " << name << ": " << time/1000.0 << " seconds" << std::endl;
159 else if (time < 1000*60*60)
160 std::cout << " " << name << ": " << time/1000.0/60.0 << " minutes" << std::endl;
161 else
162 std::cout << " " << name << ": " << time/1000.0/60.0/60.0 << " hours" << std::endl;
163 }
164 }
165 }
166
167 inline void clear()
168 {

Calls 4

name_bufFunction · 0.85
cast_to_stringFunction · 0.85
time_bufFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected