| 1 | // SuperTux |
| 2 | // Copyright (C) 2006 Matthias Braun <matze@braunis.de> |
| 3 | // 2018 Ingo Ruhnke <grumbel@gmail.com> |
| 4 | // |
| 5 | // This program is free software: you can redistribute it and/or modify |
| 6 | // it under the terms of the GNU General Public License as published by |
| 7 | // the Free Software Foundation, either version 3 of the License, or |
| 8 | // (at your option) any later version. |
| 9 | // |
| 10 | // This program is distributed in the hope that it will be useful, |
| 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | // GNU General Public License for more details. |
| 14 | // |
| 15 | // You should have received a copy of the GNU General Public License |
| 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | #include "util/timelog.hpp" |
| 19 | |
| 20 | #include <iostream> |
| 21 | |
| 22 | #include "util/log.hpp" |
| 23 | |
| 24 | Timelog::Timelog() : |
| 25 | m_last_ticks(0), |
| 26 | m_last_component(nullptr) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | void |
| 31 | Timelog::log(const char* component) |
| 32 | { |
| 33 | Uint32 current_ticks = SDL_GetTicks(); |
| 34 | |
| 35 | if (m_last_component != nullptr) { |
| 36 | log_info << "Component '" << m_last_component << "' finished after " |
| 37 | << (current_ticks - m_last_ticks) / 1000.0 << " seconds" |
| 38 | << std::endl; |
| 39 | } |
| 40 | |
| 41 | m_last_ticks = current_ticks; |
| 42 | m_last_component = component; |
| 43 | } |
| 44 | |
| 45 | /* EOF */ |
| 46 | |