17#include <geos/export.h>
32#pragma warning(disable: 4251)
44class GEOS_DLL Profile {
46 using timeunit = std::chrono::microseconds;
49 Profile(std::string name);
58 starttime = std::chrono::high_resolution_clock::now();
65 stoptime = std::chrono::high_resolution_clock::now();
66 auto elapsed = std::chrono::duration_cast<timeunit>(stoptime - starttime);
68 timings.push_back(elapsed);
71 if(timings.size() == 1) {
83 avg =
static_cast<double>(totaltime.count()) /
static_cast<double>(timings.size());
87 double getMax()
const;
90 double getMin()
const;
93 double getTot()
const;
96 std::string getTotFormatted()
const;
99 double getAvg()
const;
102 std::size_t getNumTimings()
const;
111 std::chrono::high_resolution_clock::time_point starttime, stoptime;
114 std::vector<timeunit> timings;
135class GEOS_DLL Profiler {
139 Profiler() =
default;
140 ~Profiler() =
default;
142 Profiler(
const Profiler&) =
delete;
143 Profiler& operator=(
const Profiler&) =
delete;
150 static Profiler* instance(
void);
157 void start(std::string name);
164 void stop(std::string name);
167 Profile* get(std::string name);
169 std::map<std::string, std::unique_ptr<Profile>> profs;
174GEOS_DLL std::ostream&
operator<< (std::ostream& os,
const Profile&);
177GEOS_DLL std::ostream&
operator<< (std::ostream& os,
const Profiler&);
std::ostream & operator<<(std::ostream &os, const Profile &)
Return a string representing the Profile.
Basic namespace for all GEOS functionalities.
Definition: geos.h:39