Geogram Version 1.9.6-rc
A programming library of geometric algorithms
Loading...
Searching...
No Matches
time_log.h
1/*
2 * Copyright (c) 2000-2022 Inria
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the ALICE Project-Team nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Contact: Bruno Levy
30 *
31 * https://www.inria.fr/fr/bruno-levy
32 *
33 * Inria,
34 * Domaine de Voluceau,
35 * 78150 Le Chesnay - Rocquencourt
36 * FRANCE
37 *
38 */
39
40#ifndef H_HEXDOM_ALGO_TIME_LOG_H
41#define H_HEXDOM_ALGO_TIME_LOG_H
42
44#include <string>
45#include <iostream>
46#include <vector>
47#include <time.h>
48#include <fstream>
49
58 // _ ___ ___
59 // /_\ | _ \_ _|
60 // / _ \| _/| |
61 // /_/ \_\_| |___|
62 //
63 LogTime() { post_fix = ""; }
64 ~LogTime(){}
65 // construct API
69 void add_step(const std::string& name);
70
74 void start_section(const std::string& secname, const std::string& name = "begin section");
75 void end_section();
76
80 void add_value(std::string str, double val);
81
85 void add_string(std::string str, std::string val);
86
87 // output API
88
92 void show();
96 void drop_file(std::string filename, bool append = false,unsigned int timing_depth=1000);
97
98 void set_suffix(const std::string& suffix) { post_fix=suffix; }
99 // _ _
100 // _ __ _ _(_)_ ____ _| |_ ___
101 // | '_ \ '_| \ V / _` | _/ -_)
102 // | .__/_| |_|\_/\__,_|\__\___|
103 // |_|
104
105private:
111struct CheckPoint{
112 CheckPoint(const std::string& p_n, unsigned int p_up){ n = p_n; up = p_up; t = clock(); right = (unsigned int)(-1); }
113 std::string n;
114 clock_t t;
115 unsigned int right;
116 unsigned int up;
117};
118
119bool is_start_section(unsigned int i);
120bool is_end_section(unsigned int i);
121bool is_final(unsigned int i);
122double time(unsigned int i);
123unsigned int dec(unsigned int i = (unsigned int)(-1));
124unsigned int lastdec();
125void debug();
126std::string cur_stack();
127void report(std::ostream &out, unsigned int timing_depth = 10000);
128void report_py(std::ostream &out, unsigned int timing_depth = 10000);
129
130private:
131std::string post_fix;
132std::vector<CheckPoint> check;
133std::vector<std::pair<std::string, double> > out_values;
134std::vector<std::pair<std::string, std::string> > out_strings;
135};
136
137extern EXPLORAGRAM_API LogTime logt;
138
139#endif
#define EXPLORAGRAM_API
Linkage declaration for exploragram symbols.
Definition defs.h:18
Included by all headers in exploragram.
void add_value(std::string str, double val)
void start_section(const std::string &secname, const std::string &name="begin section")
void add_string(std::string str, std::string val)
void show()
void add_step(const std::string &name)
void drop_file(std::string filename, bool append=false, unsigned int timing_depth=1000)