Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void to_string(float val, std::string &out, size_t maxLength = 5) {
- out.clear();
- std::format_to_n(std::back_inserter(out), maxLength, "{:.1f}"sv, val);
- }
- void to_string(unsigned int val, std::string &out) {
- out.clear();
- std::format_to_n(std::back_inserter(out), 3, "{}"sv, val);
- }
- void Profiler::Profile(void) {
- _endTime = GetExactTime();
- textBox.clear();
- textBox.append(header);
- std::string ave, min, max, num; //hoisted out of loop for re-se.
- for (const auto &sample : samples) {
- assert_if_invalid(sample);
- const auto sampleTime = sample.accumulator - sample.childrensTime;
- const auto percentTime = (sampleTime / (_endTime - _startTime)) * 100.0f;
- StoreProfileInHistory(sample.name, percentTime);
- const auto [aveTime, minTime, maxTime] = GetProfileFromHistory(sample.name);
- to_string(aveTime, ave);
- to_string(minTime, min);
- to_string(maxTime, max);
- to_string(sample.count, num);
- textBox += std::format("{:5} : {:5} : {:5} : {:5} : {}\n"sv,
- ave, min, max, num, indent_n(sample.parentCount, sample.name));
- }
- samples.clear();
- _startTime = GetExactTime();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement