15 #ifndef GEOS_PROFILER_H
16 #define GEOS_PROFILER_H
18 #include <geos/export.h>
33 #pragma warning(disable: 4251)
45 class GEOS_DLL Profile {
47 using timeunit = std::chrono::microseconds;
50 Profile(std::string name);
59 starttime = std::chrono::high_resolution_clock::now();
66 stoptime = std::chrono::high_resolution_clock::now();
67 auto elapsed = std::chrono::duration_cast<timeunit>(stoptime - starttime);
69 timings.push_back(elapsed);
72 if(timings.size() == 1) {
84 avg =
static_cast<double>(totaltime.count()) /
static_cast<double>(timings.size());
88 double getMax()
const;
91 double getMin()
const;
94 double getTot()
const;
97 std::string getTotFormatted()
const;
100 double getAvg()
const;
103 size_t getNumTimings()
const;
112 std::chrono::high_resolution_clock::time_point starttime, stoptime;
115 std::vector<timeunit> timings;
136 class GEOS_DLL Profiler {
140 Profiler() =
default;
141 ~Profiler() =
default;
143 Profiler(
const Profiler&) =
delete;
144 Profiler& operator=(
const Profiler&) =
delete;
151 static Profiler* instance(
void);
158 void start(std::string name);
165 void stop(std::string name);
168 Profile* get(std::string name);
170 std::map<std::string, std::unique_ptr<Profile>> profs;
175 GEOS_DLL std::ostream&
operator<< (std::ostream& os,
const Profile&);
178 GEOS_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: IndexedNestedRingTester.h:26