using std::left;
using std::right;
-static clock_t tFirstChild = 0;
-static clock_t tNextSibling = 0;
-static clock_t tParent = 0;
-static clock_t tTaggedAncestor = 0;
-static clock_t tTaggedChild = 0;
-static clock_t tTaggedDesc = 0;
-static clock_t tTaggedFoll = 0;
-static clock_t tParentNode = 0;
-static clock_t tPrevNode = 0;
-static clock_t tTag = 0;
-static clock_t tMyText = 0;
-static clock_t tPrevText = 0;
-static clock_t tNextText = 0;
-static clock_t tDocIds = 0;
-
-static clock_t tFullTraversal = 0;
-static clock_t tJumpTraversal = 0;
+static double tFirstChild = 0;
+static double tNextSibling = 0;
+static double tParent = 0;
+static double tTaggedAncestor = 0;
+static double tTaggedChild = 0;
+static double tTaggedDesc = 0;
+static double tTaggedFoll = 0;
+static double tParentNode = 0;
+static double tPrevNode = 0;
+static double tTag = 0;
+static double tMyText = 0;
+static double tPrevText = 0;
+static double tNextText = 0;
+static double tDocIds = 0;
+
+static double tFullTraversal = 0;
+static double tJumpTraversal = 0;
static unsigned int cFirstChild = 0;
static unsigned int cNextSibling = 0;
static unsigned int cJumpTraversal = 0;
-
-static clock_t tmp;
+static struct timeval tmpv1;
+static struct timeval tmpv2;
static TagType target_tag = -1;
-#define STARTTIMER() (tmp= clock())
-#define STOPTIMER(x) do { (t##x) = (t##x) + (clock() - tmp); (c##x)= (c##x)+1; } while (0)
+#define STARTTIMER() (gettimeofday(&tmpv1,NULL))
+#define STOPTIMER(x) do { \
+ gettimeofday(&tmpv2,NULL); \
+ (t##x) = (t##x) + ((tmpv2.tv_sec - tmpv1.tv_sec) * 1000000.0 + \
+ (tmpv2.tv_usec - tmpv1.tv_usec))/1000.0; \
+ (c##x)= (c##x)+1; \
+ } while (0)
+
#define PRINTSTATS(x) do { \
std::cout.width(15); \
std::cout << std::left << #x; \
std::cout << " : "; \
std::cout.width(8); \
- std::cout << std::right << c##x << " calls,"; \
+ std::cout << std::right << c##x << " calls, "; \
std::cout.width(8); \
- std::cout << std::right << t##x << " cycles, total:"; \
- std::cout.width(5); \
- std::cout << std::right << ((t##x) *1000.00) /CLOCKS_PER_SEC \
+ std::cout << std::right << (t##x) \
<< " ms, mean: "; \
- std::cout.width(5); \
+ std::cout.width(8); \
std::cout << std::right \
- << (((t##x)* 1000.00) /CLOCKS_PER_SEC) / c##x \
+ << (t##x) *1.00 / c##x \
<< "\n"; \
} while (0)
-
void traversal(XMLTree * tree, treeNode node,unsigned char* targettagname){
treeNode res1,res2;
TagType tag;
STOPTIMER(Tag);
if (target_tag == -1){
tagname = tree->GetTagNameByRef(tag);
- if (strcmp( (char*) tagname, (char*) targettagname) == 0)
- target_tag = tag;
+ //if (strcmp( (char*) tagname, (char*) targettagname) == 0)
+ target_tag = tag;
};
STARTTIMER();
res1 = tree->Parent(node);
cJumpTraversal++;
tag = tree->Tag(node);
if (tag == target_tag)
-
return 1 +
time_jump(tree, tree->TaggedDesc(node,target_tag),node) +
time_jump(tree, tree->TaggedFollBelow(node,target_tag,root), root);