--- a/include/topology/filtration.hpp Thu Sep 13 04:43:33 2007 -0400
+++ b/include/topology/filtration.hpp Thu Sep 13 10:31:39 2007 -0400
@@ -1,5 +1,5 @@
+#include "utilities/types.h"
#include "utilities/counter.h"
-#include "utilities/types.h"
#include <algorithm>
#include <boost/utility.hpp>
@@ -11,6 +11,23 @@
using boost::serialization::make_nvp;
/* Filtration Public */
+
+static Counter* cFiltrationPair = GetCounter("filtration/pair");
+static Counter* cFiltrationPairBoundaries = GetCounter("filtration/pair/boundaries");
+static Counter* cFiltrationPairCycleLength = GetCounter("filtration/pair/cyclelength");
+static Counter* cFiltrationTransposition = GetCounter("filtration/transposition");
+static Counter* cFiltrationTranspositionDiffDim = GetCounter("filtration/transposition/diffdim");
+static Counter* cFiltrationTranspositionCase1 = GetCounter("filtration/transposition/case/1");
+static Counter* cFiltrationTranspositionCase12 = GetCounter("filtration/transposition/case/1/2");
+static Counter* cFiltrationTranspositionCase112 = GetCounter("filtration/transposition/case/1/1/2");
+static Counter* cFiltrationTranspositionCase111 = GetCounter("filtration/transposition/case/1/1/1");
+static Counter* cFiltrationTranspositionCase22 = GetCounter("filtration/transposition/case/2/2");
+static Counter* cFiltrationTranspositionCase212 = GetCounter("filtration/transposition/case/2/1/2");
+static Counter* cFiltrationTranspositionCase211 = GetCounter("filtration/transposition/case/2/1/1");
+static Counter* cFiltrationTranspositionCase32 = GetCounter("filtration/transposition/case/3/2");
+static Counter* cFiltrationTranspositionCase31 = GetCounter("filtration/transposition/case/3/1");
+static Counter* cFiltrationTranspositionCase4 = GetCounter("filtration/transposition/case/4");
+
template<class S, class FS, class V>
Filtration<S, FS, V>::
@@ -34,8 +51,8 @@
Cycle& bdry = j->cycle();
Dout(dc::finish, bdry);
- CountNum("Boundaries", j->dimension());
- Count("SimplexCount");
+ CountNum(cFiltrationPairBoundaries, j->dimension());
+ Count(cFiltrationPair);
while(!bdry.empty())
{
@@ -50,7 +67,7 @@
Dout(dc::filtration, "Pairing " << *i << " and " << *j << " with cycle " << j->cycle());
i->set_pair(j);
j->set_pair(i);
- CountNum("DepositedCycleLength", j->cycle().size());
+ CountNum(cFiltrationPairCycleLength, j->cycle().size());
break;
}
@@ -171,7 +188,7 @@
transpose_simplices(Index i, bool maintain_lazy)
{
AssertMsg(is_paired(), "Pairing must be computed before transpositions");
- Count("SimplexTransposition");
+ Count(cFiltrationTransposition);
Index i_prev = i++;
@@ -179,7 +196,7 @@
{
swap(i_prev, i);
Dout(dc::transpositions, "Different dimension");
- Count("Case DiffDim");
+ Count(cFiltrationTranspositionDiffDim);
return false;
}
@@ -205,7 +222,7 @@
swap(i_prev, i);
Dout(dc::transpositions, "Case 1.2 --- unpaired");
Dout(dc::transpositions, *i_prev);
- Count("Case 1.2");
+ Count(cFiltrationTranspositionCase12);
return false;
} else if (k == i_prev)
{
@@ -215,7 +232,7 @@
swap(i_prev, i);
Dout(dc::transpositions, "Case 1.2 --- unpaired");
Dout(dc::transpositions, *i_prev);
- Count("Case 1.2");
+ Count(cFiltrationTranspositionCase12);
return false;
} else
{
@@ -224,7 +241,7 @@
pairing_switch(i_prev, i);
Dout(dc::transpositions, "Case 1.1.2 --- unpaired");
Dout(dc::transpositions, *i_prev);
- Count("Case 1.1.2");
+ Count(cFiltrationTranspositionCase112);
return true;
}
}
@@ -244,7 +261,7 @@
}
swap(i_prev, i);
Dout(dc::transpositions, "Case 1.2");
- Count("Case 1.2");
+ Count(cFiltrationTranspositionCase12);
return false;
} else
{
@@ -256,7 +273,7 @@
l->cycle().add(k->cycle(), Filtration::get_consistency_cmp()); // Add column k to l
k->trail().add(l->trail(), Filtration::get_consistency_cmp()); // Add row l to k
Dout(dc::transpositions, "Case 1.1.1");
- Count("Case 1.1.1");
+ Count(cFiltrationTranspositionCase111);
return false;
} else
{
@@ -266,7 +283,7 @@
l->trail().add(k->trail(), Filtration::get_consistency_cmp()); // Add row k to l
pairing_switch(i_prev, i);
Dout(dc::transpositions, "Case 1.1.2");
- Count("Case 1.1.2");
+ Count(cFiltrationTranspositionCase112);
return true;
}
}
@@ -278,7 +295,7 @@
// Case 2.2
swap(i_prev, i);
Dout(dc::transpositions, "Case 2.2");
- Count("Case 2.2");
+ Count(cFiltrationTranspositionCase22);
return false;
} else
{
@@ -295,13 +312,13 @@
i->trail().add(i_prev->trail(), Filtration::get_consistency_cmp()); // Add row i to i_prev
pairing_switch(i_prev, i);
Dout(dc::transpositions, "Case 2.1.2");
- Count("Case 2.1.2");
+ Count(cFiltrationTranspositionCase212);
return true;
}
// Case 2.1.1
Dout(dc::transpositions, "Case 2.1.1");
- Count("Case 2.1.1");
+ Count(cFiltrationTranspositionCase211);
return false;
}
} else if (!si && sii)
@@ -312,7 +329,7 @@
// Case 3.2
swap(i_prev, i);
Dout(dc::transpositions, "Case 3.2");
- Count("Case 3.2");
+ Count(cFiltrationTranspositionCase32);
return false;
} else
{
@@ -324,7 +341,7 @@
i->trail().add(i_prev->trail(), Filtration::get_consistency_cmp()); // Add row i to i_prev
pairing_switch(i_prev, i);
Dout(dc::transpositions, "Case 3.1");
- Count("Case 3.1");
+ Count(cFiltrationTranspositionCase31);
return true;
}
} else if (si && !sii)
@@ -338,7 +355,7 @@
}
swap(i_prev, i);
Dout(dc::transpositions, "Case 4");
- Count("Case 4");
+ Count(cFiltrationTranspositionCase4);
return false;
}
--- a/include/topology/lowerstarfiltration.hpp Thu Sep 13 04:43:33 2007 -0400
+++ b/include/topology/lowerstarfiltration.hpp Thu Sep 13 10:31:39 2007 -0400
@@ -1,4 +1,9 @@
+#include "utilities/counter.h"
+
/* Implementations */
+
+static Counter* cLowerStarTransposition = GetCounter("lowerstar");
+static Counter* cLowerStarChangedAttachment = GetCounter("lowerstar/ChangedAttachment");
template<class VI, class Smplx, class FltrSmplx, class Vnrd>
template<class VertexCmp>
@@ -59,20 +64,7 @@
LowerStarFiltration<VI,Smplx,FltrSmplx,Vnrd>::
transpose_vertices(const VertexOrderIndex& order)
{
- Count("VertexTransposition");
-
-#if COUNTERS
- if ((counters.lookup("VertexTransposition") % 1000000) == 0)
- {
- Dout(dc::lsfiltration, "Vertex transpositions: " << counters.lookup("VertexTransposition"));
- Dout(dc::lsfiltration, "Simplex transpositions: " << counters.lookup("SimplexTransposition"));
- Dout(dc::lsfiltration, "Attachment changed: " << counters.lookup("ChangedAttachment"));
- Dout(dc::lsfiltration, "Regular disconnected: " << counters.lookup("RegularDisconnected"));
- Dout(dc::lsfiltration, "Pairing Changed: " << counters.lookup("ChangedPairing"));
- Dout(dc::lsfiltration, "------------------------");
- }
-#endif // COUNTERS
-
+ Count(cLowerStarTransposition);
Dout(dc::lsfiltration, "Transposing vertices (" << order->vertex_index << ", "
<< boost::next(order)->vertex_index << ")");
@@ -103,7 +95,7 @@
Dout(dc::lsfiltration, " Considering " << *j);
if (nbghrs && j->contains(v_i)) // short circuit
{
- Count("ChangedAttachment");
+ Count(cLowerStarChangedAttachment);
Dout(dc::lsfiltration, " Attachment changed for " << *j);
j->set_attachment(v_i);
++j;
--- a/include/utilities/counter.h Thu Sep 13 04:43:33 2007 -0400
+++ b/include/utilities/counter.h Thu Sep 13 10:31:39 2007 -0400
@@ -6,37 +6,44 @@
#ifndef __COUNTER_H__
#define __COUNTER_H__
+
#ifndef COUNTERS
#define GetCounter(path) 0
#define Count(x)
+ #define CountNum(x,y)
#define SetFrequency(x, freq)
+ #define SetTrigger(x, y)
#else // COUNTERS
+ #define GetCounter(path) get_counter(path)
+ #define Count(x) do { x->count++; if ((x->count % x->frequency == 0)) x->trigger->print(); } while (0);
+ #define CountNum(x,y) do { x->subcount[y]++; } while (0);
+ #define SetFrequency(x, freq) do { x->frequency = freq; } while (0);
+ #define SetTrigger(x, y) do { x->trigger = y; } while(0);
+#endif // COUNTERS
+
#include <map>
#include <string>
#include <iostream>
-
-#define GetCounter(path) get_counter(path)
-#define Count(x) do { x->count++; if ((x->count % x->frequency == 0)) x->print(); } while (0);
-#define SetFrequency(x, freq) do { x->frequency = freq; } while (0);
-
#include <limits>
-
class Counter
{
public:
typedef unsigned long CounterType;
typedef std::map<std::string, Counter*> SubCounterMap;
+ typedef std::map<int, CounterType> SubCountMap;
public:
CounterType count;
CounterType frequency;
+ SubCountMap subcount;
+ Counter* trigger;
public:
Counter(const std::string& full_name = "",
CounterType freq = std::numeric_limits<CounterType>::max()):
- count(0), frequency(freq), full_name_(full_name)
+ count(0), frequency(freq), trigger(this), full_name_(full_name)
{}
~Counter();
@@ -58,7 +65,5 @@
#include "counter.hpp"
-#endif // COUNTERS
-
#endif // __COUNTER_H__
--- a/include/utilities/counter.hpp Thu Sep 13 04:43:33 2007 -0400
+++ b/include/utilities/counter.hpp Thu Sep 13 10:31:39 2007 -0400
@@ -35,6 +35,8 @@
{
// FIXME: add (colored) timestamp
std::cout << "Counter [" << full_name_ << "]: " << count << std::endl;
+ for (SubCountMap::const_iterator cur = subcount.begin(); cur != subcount.end(); ++cur)
+ std::cout << " " << cur->first << ": " << cur->second << std::endl;
for (SubCounterMap::iterator cur = subcounters_.begin(); cur != subcounters_.end(); ++cur)
cur->second->print();
}
--- a/tests/utilities/test-counters.cpp Thu Sep 13 04:43:33 2007 -0400
+++ b/tests/utilities/test-counters.cpp Thu Sep 13 10:31:39 2007 -0400
@@ -1,4 +1,3 @@
-#include <utilities/log.h>
#include <utilities/counter.h>
static Counter* cTestElaborate = GetCounter("test/elaborate");
@@ -18,6 +17,16 @@
Count(cTestElaborate);
Count(cTestBasic);
Count(cTestBasic);
+ CountNum(cTestBasic, 25)
+ CountNum(cTestBasic, 132)
+ CountNum(cTestBasic, 25)
+ CountNum(cTestBasic, 121)
+ CountNum(cTestBasic, 132)
+ CountNum(cTestBasic, 25)
+
+ SetTrigger(cTestBasic, &rootCounter);
+ Count(cTestBasic);
+ Count(cTestBasic);
SetFrequency(cTestElaborate, 3);
Count(cTestElaborate);