statistics.icc
Go to the documentation of this file.00001 /* 00002 * Main authors: 00003 * Christian Schulte <schulte@gecode.org> 00004 * 00005 * Copyright: 00006 * Christian Schulte, 2004 00007 * 00008 * Last modified: 00009 * $Date: 2005-08-10 20:28:01 +0200 (Wed, 10 Aug 2005) $ by $Author: schulte $ 00010 * $Revision: 2202 $ 00011 * 00012 * This file is part of Gecode, the generic constraint 00013 * development environment: 00014 * http://www.gecode.org 00015 * 00016 * See the file "LICENSE" for information on usage and 00017 * redistribution of this file, and for a 00018 * DISCLAIMER OF ALL WARRANTIES. 00019 * 00020 */ 00021 00022 namespace Gecode { namespace Search { 00023 00024 forceinline 00025 Statistics::Statistics(void) 00026 : propagate(0), fail(0), clone(0), commit(0), memory(0) {} 00027 00028 forceinline 00029 FullStatistics::FullStatistics(size_t sz) 00030 : mem_space(sz), mem_cur(0), mem_total(0) { 00031 memory = 0; 00032 } 00033 00034 forceinline void 00035 FullStatistics::push(const Space* s) { 00036 mem_total += mem_space + s->allocated(); 00037 if (mem_total > memory) 00038 memory = mem_total; 00039 } 00040 00041 forceinline void 00042 FullStatistics::push(const Space* s, const BranchingDesc* d) { 00043 if (s != NULL) 00044 mem_total += mem_space + s->allocated(); 00045 if (d != NULL) 00046 mem_total += d->size(); 00047 if (mem_total > memory) 00048 memory = mem_total; 00049 } 00050 00051 forceinline void 00052 FullStatistics::pop(const Space* s) { 00053 mem_total -= mem_space + s->allocated(); 00054 } 00055 00056 forceinline void 00057 FullStatistics::pop(const Space* s, const BranchingDesc* d) { 00058 if (s != NULL) 00059 mem_total -= mem_space + s->allocated(); 00060 if (d != NULL) 00061 mem_total -= d->size(); 00062 } 00063 00064 forceinline void 00065 FullStatistics::current(const Space* s) { 00066 if (s == NULL) { 00067 mem_total -= mem_cur; 00068 mem_cur = 0; 00069 } else { 00070 mem_cur = mem_space + s->allocated() + s->cached(); 00071 mem_total += mem_cur; 00072 if (mem_total > memory) 00073 memory = mem_total; 00074 } 00075 } 00076 00077 forceinline void 00078 FullStatistics::reset(const Space* s) { 00079 mem_cur = mem_space+s->allocated()+s->cached(); 00080 mem_total = mem_cur; 00081 if (mem_total > memory) 00082 memory = mem_total; 00083 } 00084 00085 }} 00086 00087 // STATISTICS: search-any