Fossil SCM

Add the --stats option to the rebuild command.

drh 2011-09-27 16:34 trunk
Commit f25e5e53c473a87598d1290bb8ceada0bc85b9c0
+1
--- src/main.c
+++ src/main.c
@@ -150,10 +150,11 @@
150150
151151
/* For defense against Cross-site Request Forgery attacks */
152152
char zCsrfToken[12]; /* Value of the anti-CSRF token */
153153
int okCsrf; /* Anti-CSRF token is present and valid */
154154
155
+ int parseCnt[10]; /* Counts of artifacts parsed */
155156
FILE *fDebug; /* Write debug information here, if the file exists */
156157
int thTrace; /* True to enable TH1 debugging output */
157158
Blob thLog; /* Text of the TH1 debugging output */
158159
159160
int isHome; /* True if rendering the "home" page */
160161
--- src/main.c
+++ src/main.c
@@ -150,10 +150,11 @@
150
151 /* For defense against Cross-site Request Forgery attacks */
152 char zCsrfToken[12]; /* Value of the anti-CSRF token */
153 int okCsrf; /* Anti-CSRF token is present and valid */
154
 
155 FILE *fDebug; /* Write debug information here, if the file exists */
156 int thTrace; /* True to enable TH1 debugging output */
157 Blob thLog; /* Text of the TH1 debugging output */
158
159 int isHome; /* True if rendering the "home" page */
160
--- src/main.c
+++ src/main.c
@@ -150,10 +150,11 @@
150
151 /* For defense against Cross-site Request Forgery attacks */
152 char zCsrfToken[12]; /* Value of the anti-CSRF token */
153 int okCsrf; /* Anti-CSRF token is present and valid */
154
155 int parseCnt[10]; /* Counts of artifacts parsed */
156 FILE *fDebug; /* Write debug information here, if the file exists */
157 int thTrace; /* True to enable TH1 debugging output */
158 Blob thLog; /* Text of the TH1 debugging output */
159
160 int isHome; /* True if rendering the "home" page */
161
--- src/manifest.c
+++ src/manifest.c
@@ -345,14 +345,24 @@
345345
char cType;
346346
char *z;
347347
int n;
348348
char *zUuid;
349349
int sz = 0;
350
+ int isRepeat;
351
+ static Bag seen;
352
+
353
+ if( bag_find(&seen, rid) ){
354
+ isRepeat = 1;
355
+ }else{
356
+ isRepeat = 0;
357
+ bag_insert(&seen, rid);
358
+ }
350359
351360
/* Every control artifact ends with a '\n' character. Exit early
352361
** if that is not the case for this artifact.
353362
*/
363
+ if( !isRepeat ) g.parseCnt[0]++;
354364
z = blob_materialize(pContent);
355365
n = blob_size(pContent);
356366
if( n<=0 || z[n-1]!='\n' ){
357367
blob_reset(pContent);
358368
return 0;
@@ -885,10 +895,11 @@
885895
if( p->zWikiTitle ) goto manifest_syntax_error;
886896
if( p->zTicketUuid ) goto manifest_syntax_error;
887897
p->type = CFTYPE_MANIFEST;
888898
}
889899
md5sum_init();
900
+ if( !isRepeat ) g.parseCnt[p->type]++;
890901
return p;
891902
892903
manifest_syntax_error:
893904
/*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/
894905
md5sum_init();
895906
--- src/manifest.c
+++ src/manifest.c
@@ -345,14 +345,24 @@
345 char cType;
346 char *z;
347 int n;
348 char *zUuid;
349 int sz = 0;
 
 
 
 
 
 
 
 
 
350
351 /* Every control artifact ends with a '\n' character. Exit early
352 ** if that is not the case for this artifact.
353 */
 
354 z = blob_materialize(pContent);
355 n = blob_size(pContent);
356 if( n<=0 || z[n-1]!='\n' ){
357 blob_reset(pContent);
358 return 0;
@@ -885,10 +895,11 @@
885 if( p->zWikiTitle ) goto manifest_syntax_error;
886 if( p->zTicketUuid ) goto manifest_syntax_error;
887 p->type = CFTYPE_MANIFEST;
888 }
889 md5sum_init();
 
890 return p;
891
892 manifest_syntax_error:
893 /*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/
894 md5sum_init();
895
--- src/manifest.c
+++ src/manifest.c
@@ -345,14 +345,24 @@
345 char cType;
346 char *z;
347 int n;
348 char *zUuid;
349 int sz = 0;
350 int isRepeat;
351 static Bag seen;
352
353 if( bag_find(&seen, rid) ){
354 isRepeat = 1;
355 }else{
356 isRepeat = 0;
357 bag_insert(&seen, rid);
358 }
359
360 /* Every control artifact ends with a '\n' character. Exit early
361 ** if that is not the case for this artifact.
362 */
363 if( !isRepeat ) g.parseCnt[0]++;
364 z = blob_materialize(pContent);
365 n = blob_size(pContent);
366 if( n<=0 || z[n-1]!='\n' ){
367 blob_reset(pContent);
368 return 0;
@@ -885,10 +895,11 @@
895 if( p->zWikiTitle ) goto manifest_syntax_error;
896 if( p->zTicketUuid ) goto manifest_syntax_error;
897 p->type = CFTYPE_MANIFEST;
898 }
899 md5sum_init();
900 if( !isRepeat ) g.parseCnt[p->type]++;
901 return p;
902
903 manifest_syntax_error:
904 /*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/
905 md5sum_init();
906
--- src/rebuild.c
+++ src/rebuild.c
@@ -500,10 +500,11 @@
500500
** --noverify Skip the verification of changes to the BLOB table
501501
** --pagesize N Set the database pagesize to N. (512..65536 and power of 2)
502502
** --randomize Scan artifacts in a random order
503503
** --vacuum Run VACUUM on the database after rebuilding
504504
** --wal Set Write-Ahead-Log journalling mode on the database
505
+** --stats Show artifact statistics after rebuilding
505506
**
506507
** See also: deconstruct, reconstruct
507508
*/
508509
void rebuild_database(void){
509510
int forceFlag;
@@ -514,18 +515,20 @@
514515
const char *zPagesize;
515516
int newPagesize = 0;
516517
int activateWal;
517518
int runVacuum;
518519
int runCompress;
520
+ int showStats;
519521
520522
omitVerify = find_option("noverify",0,0)!=0;
521523
forceFlag = find_option("force","f",0)!=0;
522524
randomizeFlag = find_option("randomize", 0, 0)!=0;
523525
doClustering = find_option("cluster", 0, 0)!=0;
524526
runVacuum = find_option("vacuum",0,0)!=0;
525527
runCompress = find_option("compress",0,0)!=0;
526528
zPagesize = find_option("pagesize",0,1);
529
+ showStats = find_option("stats",0,0)!=0;
527530
if( zPagesize ){
528531
newPagesize = atoi(zPagesize);
529532
if( newPagesize<512 || newPagesize>65536
530533
|| (newPagesize&(newPagesize-1))!=0
531534
){
@@ -579,10 +582,30 @@
579582
}
580583
if( activateWal ){
581584
db_multi_exec("PRAGMA journal_mode=WAL;");
582585
}
583586
}
587
+ if( showStats ){
588
+ static struct { int idx; const char *zLabel; } aStat[] = {
589
+ { CFTYPE_ANY, "Artifacts:" },
590
+ { CFTYPE_MANIFEST, "Manifests:" },
591
+ { CFTYPE_CLUSTER, "Clusters:" },
592
+ { CFTYPE_CONTROL, "Tags:" },
593
+ { CFTYPE_WIKI, "Wikis:" },
594
+ { CFTYPE_TICKET, "Tickets:" },
595
+ { CFTYPE_ATTACHMENT,"Attachments:" },
596
+ { CFTYPE_EVENT, "Events:" },
597
+ };
598
+ int i;
599
+ int subtotal = 0;
600
+ for(i=0; i<count(aStat); i++){
601
+ int k = aStat[i].idx;
602
+ fossil_print("%-15s %6d\n", aStat[i].zLabel, g.parseCnt[k]);
603
+ if( k>0 ) subtotal += g.parseCnt[k];
604
+ }
605
+ fossil_print("%-15s %6d\n", "Other:", g.parseCnt[CFTYPE_ANY] - subtotal);
606
+ }
584607
}
585608
586609
/*
587610
** COMMAND: test-detach ?REPOSITORY?
588611
**
589612
--- src/rebuild.c
+++ src/rebuild.c
@@ -500,10 +500,11 @@
500 ** --noverify Skip the verification of changes to the BLOB table
501 ** --pagesize N Set the database pagesize to N. (512..65536 and power of 2)
502 ** --randomize Scan artifacts in a random order
503 ** --vacuum Run VACUUM on the database after rebuilding
504 ** --wal Set Write-Ahead-Log journalling mode on the database
 
505 **
506 ** See also: deconstruct, reconstruct
507 */
508 void rebuild_database(void){
509 int forceFlag;
@@ -514,18 +515,20 @@
514 const char *zPagesize;
515 int newPagesize = 0;
516 int activateWal;
517 int runVacuum;
518 int runCompress;
 
519
520 omitVerify = find_option("noverify",0,0)!=0;
521 forceFlag = find_option("force","f",0)!=0;
522 randomizeFlag = find_option("randomize", 0, 0)!=0;
523 doClustering = find_option("cluster", 0, 0)!=0;
524 runVacuum = find_option("vacuum",0,0)!=0;
525 runCompress = find_option("compress",0,0)!=0;
526 zPagesize = find_option("pagesize",0,1);
 
527 if( zPagesize ){
528 newPagesize = atoi(zPagesize);
529 if( newPagesize<512 || newPagesize>65536
530 || (newPagesize&(newPagesize-1))!=0
531 ){
@@ -579,10 +582,30 @@
579 }
580 if( activateWal ){
581 db_multi_exec("PRAGMA journal_mode=WAL;");
582 }
583 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584 }
585
586 /*
587 ** COMMAND: test-detach ?REPOSITORY?
588 **
589
--- src/rebuild.c
+++ src/rebuild.c
@@ -500,10 +500,11 @@
500 ** --noverify Skip the verification of changes to the BLOB table
501 ** --pagesize N Set the database pagesize to N. (512..65536 and power of 2)
502 ** --randomize Scan artifacts in a random order
503 ** --vacuum Run VACUUM on the database after rebuilding
504 ** --wal Set Write-Ahead-Log journalling mode on the database
505 ** --stats Show artifact statistics after rebuilding
506 **
507 ** See also: deconstruct, reconstruct
508 */
509 void rebuild_database(void){
510 int forceFlag;
@@ -514,18 +515,20 @@
515 const char *zPagesize;
516 int newPagesize = 0;
517 int activateWal;
518 int runVacuum;
519 int runCompress;
520 int showStats;
521
522 omitVerify = find_option("noverify",0,0)!=0;
523 forceFlag = find_option("force","f",0)!=0;
524 randomizeFlag = find_option("randomize", 0, 0)!=0;
525 doClustering = find_option("cluster", 0, 0)!=0;
526 runVacuum = find_option("vacuum",0,0)!=0;
527 runCompress = find_option("compress",0,0)!=0;
528 zPagesize = find_option("pagesize",0,1);
529 showStats = find_option("stats",0,0)!=0;
530 if( zPagesize ){
531 newPagesize = atoi(zPagesize);
532 if( newPagesize<512 || newPagesize>65536
533 || (newPagesize&(newPagesize-1))!=0
534 ){
@@ -579,10 +582,30 @@
582 }
583 if( activateWal ){
584 db_multi_exec("PRAGMA journal_mode=WAL;");
585 }
586 }
587 if( showStats ){
588 static struct { int idx; const char *zLabel; } aStat[] = {
589 { CFTYPE_ANY, "Artifacts:" },
590 { CFTYPE_MANIFEST, "Manifests:" },
591 { CFTYPE_CLUSTER, "Clusters:" },
592 { CFTYPE_CONTROL, "Tags:" },
593 { CFTYPE_WIKI, "Wikis:" },
594 { CFTYPE_TICKET, "Tickets:" },
595 { CFTYPE_ATTACHMENT,"Attachments:" },
596 { CFTYPE_EVENT, "Events:" },
597 };
598 int i;
599 int subtotal = 0;
600 for(i=0; i<count(aStat); i++){
601 int k = aStat[i].idx;
602 fossil_print("%-15s %6d\n", aStat[i].zLabel, g.parseCnt[k]);
603 if( k>0 ) subtotal += g.parseCnt[k];
604 }
605 fossil_print("%-15s %6d\n", "Other:", g.parseCnt[CFTYPE_ANY] - subtotal);
606 }
607 }
608
609 /*
610 ** COMMAND: test-detach ?REPOSITORY?
611 **
612

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button