1. Erik van Zijst
  2. libgitwalker

Commits

Erik van Zijst  committed d183e0d

added measurements

  • Participants
  • Parent commits ce9e233
  • Branches default

Comments (0)

Files changed (1)

File walk.c

View file
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <errno.h>
 
 /*
  * Repository walker using libgit2.
  *
+ * Usage:
  * $ gcc -lgit2 -o walk walk.c
- * $ ./walk <repo> <commit>
+ * $ ./walk <repo> <commit> [iterations]
+ * 
+ * Results:
+ * $ ./walk git/.git 4b5eac7f03f411f75087e0b6db23caa999624304
+ * 
+ * 1x:		1.178s
+ * 2x:		1.8s
+ * 4x:		3.0s
+ * 8x:		5.5s
+ * 16x:		10.5s
+ * 
+ * Initial sort & traversal:		1.178s
+ * Subsequent traversals (each):	0.58s
  */
 int main(int argc, char *args[])
 {
 
 	char out[41];
 	out[40] = '\0';
-	int i;
+	long i;
 
-	for (i = 0; i < 2; i++) {
-		printf("Iteration: %d\n", i);
+	long count = (argc >= 4 ? strtol(args[3], NULL, 10) : 1);
+	for (i = 0; i < count; i++) {
 		
 		git_revwalk_sorting(walk, GIT_SORT_TOPOLOGICAL);
 		git_oid_fromstr(&oid, args[2]);
 			git_commit_close(wcommit);
 		}
 		git_revwalk_reset(walk);
+		printf("\n");
 	}
 	
 	return 0;