ofs | hex dump | ascii |
---|
0000 | 42 42 33 44 1d 33 00 00 01 00 00 00 54 45 58 53 36 00 00 00 61 64 76 74 72 61 69 6e 73 5f 72 65 | BB3D.3......TEXS6...advtrains_re |
0020 | 74 72 6f 73 69 67 6e 61 6c 2e 70 6e 67 00 01 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 | trosignal.png................... |
0040 | 80 3f 00 00 80 3f 00 00 00 00 42 52 55 53 2e 00 00 00 01 00 00 00 42 72 75 73 68 2e 30 30 31 00 | .?...?....BRUS........Brush.001. |
0060 | 00 00 80 3f 00 00 80 3f 00 00 80 3f 00 00 80 3f 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 | ...?...?...?...?................ |
0080 | 4e 4f 44 45 9d 32 00 00 43 75 62 65 2e 30 30 30 00 00 00 80 b0 00 00 00 00 00 00 00 00 fe ff 7f | NODE.2..Cube.000................ |
00a0 | 3f 00 00 80 3f 00 00 80 3f ea 40 6d 3e 2f b8 a5 bd bb 5b 66 bf 42 a6 b8 3e 4d 45 53 48 64 32 00 | ?...?...?.@m>/....[f.B..>MESHd2. |
00c0 | 00 ff ff ff ff 56 52 54 53 8c 2b 00 00 01 00 00 00 01 00 00 00 02 00 00 00 e3 35 af bd 39 fa ba | .....VRTS.+...............5..9.. |
00e0 | 3f be 50 76 bf 28 cd 13 bf 28 cd 13 bf 28 cd 13 3f 98 e5 52 3f f6 af 5f 3f e3 35 af bd 39 fa ba | ?.Pv.(...(...(..?..R?.._?.5..9.. |
0100 | 3f 0c c6 3b c0 6a 03 35 bf 6a 03 35 bf 00 00 00 00 36 c7 86 3e ff af 5f 3f e3 35 af bd c7 36 dd | ?..;.j.5.j.5.....6..>.._?.5...6. |
0120 | 3f 0c c6 3b c0 6a 03 35 bf 6a 03 35 3f 00 00 00 00 34 c7 86 3e 7d 38 4c 3f e3 35 af bd c7 36 dd | ?..;.j.5.j.5?....4..>}8L?.5...6. |
0140 | 3f be 50 76 bf 28 cd 13 bf 28 cd 13 3f 28 cd 13 3f 96 e5 52 3f 77 38 4c 3f e3 35 af bd c7 36 dd | ?.Pv.(...(..?(..?..R?w8L?.5...6. |
0160 | 3f be 50 76 bf 28 cd 13 bf 28 cd 13 3f 28 cd 13 3f 96 e5 52 3f 77 38 4c 3f 6a 5d a5 bc c7 36 dd | ?.Pv.(...(..?(..?..R?w8L?j]...6. |
0180 | 3f be 50 76 bf 28 cd 13 3f 28 cd 13 3f 28 cd 13 3f 96 e5 52 3f 95 76 47 3f 6a 5d a5 bc 39 fa ba | ?.Pv.(..?(..?(..?..R?.vG?j]..9.. |
01a0 | 3f be 50 76 bf 28 cd 13 3f 28 cd 13 bf 28 cd 13 3f 18 5d 66 3f 94 76 47 3f e3 35 af bd 39 fa ba | ?.Pv.(..?(...(..?.]f?.vG?.5..9.. |
01c0 | 3f be 50 76 bf 28 cd 13 bf 28 cd 13 bf 28 cd 13 3f 18 5d 66 3f 77 38 4c 3f 6a 5d a5 bc c7 36 dd | ?.Pv.(...(...(..?.]f?w8L?j]...6. |
01e0 | 3f be 50 76 bf 28 cd 13 3f 28 cd 13 3f 28 cd 13 3f 96 e5 52 3f 59 e9 77 3f 6a 5d a5 bc c7 36 dd | ?.Pv.(..?(..?(..?..R?Y.w?j]...6. |
0200 | 3f 0c c6 3b c0 6a 03 35 3f 6a 03 35 3f 00 00 00 00 34 c7 86 3e 4c e9 77 3f 6a 5d a5 bc 39 fa ba | ?..;.j.5?j.5?....4..>L.w?j]..9.. |
0220 | 3f 0c c6 3b c0 6a 03 35 3f 6a 03 35 bf 00 00 00 00 3c c7 86 3e ce 71 64 3f 6a 5d a5 bc 39 fa ba | ?..;.j.5?j.5.....<..>.qd?j]..9.. |
0240 | 3f be 50 76 bf 28 cd 13 3f 28 cd 13 bf 28 cd 13 3f 99 e5 52 3f d8 71 64 3f e3 35 af bd 39 fa ba | ?.Pv.(..?(...(..?..R?.qd?.5..9.. |
0260 | 3f 0c c6 3b c0 6a 03 35 bf 6a 03 35 bf 00 00 00 00 36 c7 86 3e ff af 5f 3f e3 35 af bd 39 fa ba | ?..;.j.5.j.5.....6..>.._?.5..9.. |
0280 | 3f be 50 76 bf 28 cd 13 bf 28 cd 13 bf 28 cd 13 3f 98 e5 52 3f f6 af 5f 3f 6a 5d a5 bc 39 fa ba | ?.Pv.(...(...(..?..R?.._?j]..9.. |
02a0 | 3f be 50 76 bf 28 cd 13 3f 28 cd 13 bf 28 cd 13 3f 99 e5 52 3f d8 71 64 3f 6a/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2018 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "porting.h"
#include "profilergraph.h"
#include "util/string.h"
void ProfilerGraph::put(const Profiler::GraphValues &values)
{
m_log.emplace_back(values);
while (m_log.size() > m_log_max_size)
m_log.erase(m_log.begin());
}
void ProfilerGraph::draw(s32 x_left, s32 y_bottom, video::IVideoDriver *driver,
gui::IGUIFont *font) const
{
// Do *not* use UNORDERED_MAP here as the order needs
// to be the same for each call to prevent flickering
std::map<std::string, Meta> m_meta;
for (const Piece &piece : m_log) {
for (const auto &i : piece.values) {
const std::string &id = i.first;
const float &value = i.second;
std::map<std::string, Meta>::iterator j = m_meta.find(id);
if (j == m_meta.end()) {
m_meta[id] = Meta(value);
continue;
}
if (value < j->second.min)
j->second.min = value;
if (value > j->second.max)
j->second.max = value;
}
}
// Assign colors
static const video::SColor usable_colors[] = {video::SColor(255, 255, 100, 100),
video::SColor(255, 90, 225, 90),
video::SColor(255, 100, 100, 255),
video::SColor(255, 255, 150, 50),
video::SColor(255, 220, 220, 100)};
static const u32 usable_colors_count =
sizeof(usable_colors) / sizeof(*usable_colors);
u32 next_color_i = 0;
for (auto &i : m_meta) {
Meta &meta = i.second;
video::SColor color(255, 200, 200, 200);
if (next_color_i < usable_colors_count)
color = usable_colors[next_color_i++];
meta.color = color;
}
s32 graphh = 50;
s32 textx = x_left + m_log_max_size + 15;
s32 textx2 = textx + 200 - 15;
s32 meta_i = 0;
for (const auto &p : m_meta) {
const std::string &id = p.first;
const Meta &meta = p.second;
s32 x = x_left;
s32 y = y_bottom - meta_i * 50;
float show_min = meta.min;
float show_max = meta.max;
if (show_min >= -0.0001 && show_max >= -0.0001) {
if (show_min <= show_max * 0.5)
show_min = 0;
}
s32 texth = 15;
char buf[10];
porting::mt_snprintf(buf, sizeof(buf), "%.3g", show_max);
font->draw(utf8_to_wide(buf).c_str(),
core::rect<s32>(textx, y - graphh, textx2,
y - graphh + texth),
meta.color);
porting::mt_snprintf(buf, sizeof(buf), "%.3g", show_min);
font->draw(utf8_to_wide(buf).c_str(),
core::rect<s32>(textx, y - texth, textx2, y), meta.color);
font->draw(utf8_to_wide(id).c_str(),
core::rect<s32>(textx, y - graphh / 2 - texth / 2, textx2,
y - graphh / 2 + texth / 2),
meta.color);
s32 graph1y = y;
s32 graph1h = graphh;
bool relativegraph = (show_min != 0 && show_min != show_max);
float lastscaledvalue = 0.0;
bool lastscaledvalue_exists = false;
for (const Piece &piece : m_log) {
float value = 0;
bool value_exists = false;
Profiler::GraphValues::const_iterator k = piece.values.find(id);
if (k != piece.values.end()) {
value = k->second;
value_exists = true;
}
if (!value_exists) {
x++;
lastscaledvalue_exists = false;
continue;
}
float scaledvalue = 1.0;
if (show_max != show_min)
scaledvalue = (value - show_min) / (show_max - show_min);
if (scaledvalue == 1.0 && value == 0) {
x++;
lastscaledvalue_exists = false;
continue;
}
if (relativegraph) {
if (lastscaledvalue_exists) {
s32 ivalue1 = lastscaledvalue * graph1h;
s32 ivalue2 = scaledvalue * graph1h;
driver->draw2DLine(
v2s32(x - 1, graph1y - ivalue1),
v2s32(x, graph1y - ivalue2),
meta.color);
}
lastscaledvalue = scaledvalue;
lastscaledvalue_exists = true;
} else {
s32 ivalue = scaledvalue * graph1h;
driver->draw2DLine(v2s32(x, graph1y),
v2s32(x, graph1y - ivalue), meta.color);
}
x++;
}
meta_i++;
}
}
|