Fossil SCM

Enhance the test-delta-analyze command to show the size of the delta.

drh 2015-12-25 15:13 trunk
Commit 138313df99a6bbf16078897a5346e45c2046ad8b
1 file changed +3 -1
+3 -1
--- src/deltacmd.c
+++ src/deltacmd.c
@@ -80,11 +80,11 @@
8080
*/
8181
void delta_analyze_cmd(void){
8282
Blob orig, target, delta;
8383
int nCopy = 0;
8484
int nInsert = 0;
85
- int sz1, sz2;
85
+ int sz1, sz2, sz3;
8686
if( g.argc!=4 ){
8787
usage("ORIGIN TARGET");
8888
}
8989
if( blob_read_from_file(&orig, g.argv[2])<0 ){
9090
fossil_fatal("cannot read %s\n", g.argv[2]);
@@ -94,19 +94,21 @@
9494
}
9595
blob_delta_create(&orig, &target, &delta);
9696
delta_analyze(blob_buffer(&delta), blob_size(&delta), &nCopy, &nInsert);
9797
sz1 = blob_size(&orig);
9898
sz2 = blob_size(&target);
99
+ sz3 = blob_size(&delta);
99100
blob_reset(&orig);
100101
blob_reset(&target);
101102
blob_reset(&delta);
102103
fossil_print("original size: %8d\n", sz1);
103104
fossil_print("bytes copied: %8d (%.1f%% of target)\n",
104105
nCopy, (100.0*nCopy)/sz2);
105106
fossil_print("bytes inserted: %8d (%.1f%% of target)\n",
106107
nInsert, (100.0*nInsert)/sz2);
107108
fossil_print("final size: %8d\n", sz2);
109
+ fossil_print("delta size: %8d\n", sz3);
108110
}
109111
110112
/*
111113
** Apply the delta in pDelta to the original file pOriginal to generate
112114
** the target file pTarget. The pTarget blob is initialized by this
113115
--- src/deltacmd.c
+++ src/deltacmd.c
@@ -80,11 +80,11 @@
80 */
81 void delta_analyze_cmd(void){
82 Blob orig, target, delta;
83 int nCopy = 0;
84 int nInsert = 0;
85 int sz1, sz2;
86 if( g.argc!=4 ){
87 usage("ORIGIN TARGET");
88 }
89 if( blob_read_from_file(&orig, g.argv[2])<0 ){
90 fossil_fatal("cannot read %s\n", g.argv[2]);
@@ -94,19 +94,21 @@
94 }
95 blob_delta_create(&orig, &target, &delta);
96 delta_analyze(blob_buffer(&delta), blob_size(&delta), &nCopy, &nInsert);
97 sz1 = blob_size(&orig);
98 sz2 = blob_size(&target);
 
99 blob_reset(&orig);
100 blob_reset(&target);
101 blob_reset(&delta);
102 fossil_print("original size: %8d\n", sz1);
103 fossil_print("bytes copied: %8d (%.1f%% of target)\n",
104 nCopy, (100.0*nCopy)/sz2);
105 fossil_print("bytes inserted: %8d (%.1f%% of target)\n",
106 nInsert, (100.0*nInsert)/sz2);
107 fossil_print("final size: %8d\n", sz2);
 
108 }
109
110 /*
111 ** Apply the delta in pDelta to the original file pOriginal to generate
112 ** the target file pTarget. The pTarget blob is initialized by this
113
--- src/deltacmd.c
+++ src/deltacmd.c
@@ -80,11 +80,11 @@
80 */
81 void delta_analyze_cmd(void){
82 Blob orig, target, delta;
83 int nCopy = 0;
84 int nInsert = 0;
85 int sz1, sz2, sz3;
86 if( g.argc!=4 ){
87 usage("ORIGIN TARGET");
88 }
89 if( blob_read_from_file(&orig, g.argv[2])<0 ){
90 fossil_fatal("cannot read %s\n", g.argv[2]);
@@ -94,19 +94,21 @@
94 }
95 blob_delta_create(&orig, &target, &delta);
96 delta_analyze(blob_buffer(&delta), blob_size(&delta), &nCopy, &nInsert);
97 sz1 = blob_size(&orig);
98 sz2 = blob_size(&target);
99 sz3 = blob_size(&delta);
100 blob_reset(&orig);
101 blob_reset(&target);
102 blob_reset(&delta);
103 fossil_print("original size: %8d\n", sz1);
104 fossil_print("bytes copied: %8d (%.1f%% of target)\n",
105 nCopy, (100.0*nCopy)/sz2);
106 fossil_print("bytes inserted: %8d (%.1f%% of target)\n",
107 nInsert, (100.0*nInsert)/sz2);
108 fossil_print("final size: %8d\n", sz2);
109 fossil_print("delta size: %8d\n", sz3);
110 }
111
112 /*
113 ** Apply the delta in pDelta to the original file pOriginal to generate
114 ** the target file pTarget. The pTarget blob is initialized by this
115

Keyboard Shortcuts

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