2012-11-05 08:04:57 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2012-11-05 08:04:57 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2012-11-05 08:04:57 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-11-05 08:04:57 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License
|
2012-11-05 08:04:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UTIL_STATS_H__
|
|
|
|
#define __UTIL_STATS_H__
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class Stats {
|
|
|
|
public:
|
2012-11-09 08:47:08 +00:00
|
|
|
Stats() : mem_used(0), mem_peak(0) {}
|
2012-11-05 08:04:57 +00:00
|
|
|
|
|
|
|
void mem_alloc(size_t size) {
|
|
|
|
mem_used += size;
|
|
|
|
if(mem_used > mem_peak)
|
|
|
|
mem_peak = mem_used;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mem_free(size_t size) {
|
2014-09-04 11:22:40 +00:00
|
|
|
assert(mem_used >= size);
|
2012-11-05 08:04:57 +00:00
|
|
|
mem_used -= size;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t mem_used;
|
|
|
|
size_t mem_peak;
|
|
|
|
};
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __UTIL_STATS_H__ */
|