1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
// Copyright (c) 2012-2013, IGN France.
// Copyright (c) 2012-2024, Oslandia.
// Copyright (c) 2024-2025, SFCGAL team.
// SPDX-License-Identifier: LGPL-2.0-or-later
#include "Bench.h"
namespace SFCGAL {
Bench::~Bench() {}
void
Bench::start(const std::string &description)
{
_timers.push(std::make_pair(description, timer_t()));
_timers.top().second.start();
}
void
Bench::start(const boost::basic_format<char> &description)
{
start(description.str());
}
void
Bench::stop()
{
BOOST_ASSERT(!_timers.empty());
_timers.top().second.stop();
s() << _timers.top().first << "\t"
<< (_timers.top().second.elapsed().wall * 1.0e-9) << std::endl;
_timers.pop();
}
Bench &
Bench::instance()
{
static Bench bench;
return bench;
}
std::ostream &
Bench::s()
{
return *_s;
}
Bench::Bench() : _s(&std::cout) {}
} // namespace SFCGAL
|