Geophysical Inversion and Modelling Library v1.5.4
Loading...
Searching...
No Matches
memwatch.h
1/******************************************************************************
2 * Copyright (C) 2012-2024 by the GIMLi development team *
3 * Carsten Rücker carsten@resistivity.net *
4 * *
5 * Licensed under the Apache License, Version 2.0 (the "License"); *
6 * you may not use this file except in compliance with the License. *
7 * You may obtain a copy of the License at *
8 * *
9 * http://www.apache.org/licenses/LICENSE-2.0 *
10 * *
11 * Unless required by applicable law or agreed to in writing, software *
12 * distributed under the License is distributed on an "AS IS" BASIS, *
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14 * See the License for the specific language governing permissions and *
15 * limitations under the License. *
16 * *
17 ******************************************************************************/
18
19#ifndef _GIMLI_MEMWATCH__H
20#define _GIMLI_MEMWATCH__H
21
22#include "gimli.h"
23
24#define MEMINFO GIMLI::MemWatch::instance().info(WHERE);
25
26namespace GIMLI{
27
29inline double KByte(long byte){ return double(byte / 1024.0); }
30
32inline double MByte(long byte){ return double(byte / (1024.0 * 1024.0)); }
33
35inline double GByte(long byte){ return double(byte / (1024.0 * 1024.0 * 1024)); }
36
38
42class DLLEXPORT MemWatch : public Singleton< MemWatch > {
43public:
44 friend class Singleton< MemWatch >;
45
47 double inUse();
48
50 double current();
51
53 void info(const std::string & str="");
54
55protected:
56 double last_;
57
58private:
60 MemWatch();
62 virtual ~MemWatch();
64 MemWatch(const MemWatch &){};
66 void operator = (const MemWatch &){ };
67
68 Stopwatch * swatchAll_;
69 Stopwatch * swatchDur_;
70
71};
72
74inline double memoryInUse(){
76}
77
78DLLEXPORT long maxMem();
79
80} // namespace GIMLI
81
82#endif
void info(const std::string &str="")
Definition memwatch.cpp:102
double inUse()
Definition memwatch.cpp:65
double current()
Definition memwatch.cpp:59
Singleton()
Definition gimli.h:634
static MemWatch & instance()
Definition gimli.h:628
Definition stopwatch.h:62
GIMLi main namespace for the Geophyiscal Inversion and Modelling Library.
Definition baseentity.h:24
double MByte(long byte)
Definition memwatch.h:32
double KByte(long byte)
Definition memwatch.h:29
double GByte(long byte)
Definition memwatch.h:35
double memoryInUse()
Definition memwatch.h:74