comparison OrthancStone/Sources/Toolbox/TimerLogger.cpp @ 2068:22a83fb9dd23 deep-learning

added AlignedMatrix and TimerLogger
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 May 2023 17:30:52 +0200
parents
children
comparison
equal deleted inserted replaced
2067:20222330cdf6 2068:22a83fb9dd23
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
7 *
8 * This program is free software: you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
21 **/
22
23
24 #include "TimerLogger.h"
25
26 #include <Logging.h>
27
28
29 namespace OrthancStone
30 {
31 TimerLogger::TimerLogger(const std::string& name) :
32 name_(name)
33 {
34 #if defined(__EMSCRIPTEN__)
35 start_ = emscripten_get_now();
36 #else
37 start_ = boost::posix_time::microsec_clock::universal_time();
38 #endif
39 }
40
41
42 TimerLogger::~TimerLogger()
43 {
44 #if defined(__EMSCRIPTEN__)
45 int elapsed = static_cast<int>(round(emscripten_get_now() - start_));
46 #else
47 const boost::posix_time::ptime end = boost::posix_time::microsec_clock::universal_time();
48 int elapsed = (end - start_).total_milliseconds();
49 #endif
50
51 LOG(WARNING) << name_ << " - Elapsed time: " << elapsed << "ms";
52 }
53 }