@@ -77,21 +77,48 @@ func runStats(file string) error {
77
77
keys := maps .Keys (s )
78
78
slices .Sort (keys )
79
79
80
+ var (
81
+ totalCompressedSize int64
82
+ totalUncompressedSize int64
83
+ totalByteSize int64
84
+ )
80
85
for _ , k := range keys {
81
86
row := s [k ]
82
- table .Append (
83
- []string {
84
- k ,
85
- row .Type ,
86
- fmt .Sprintf ("%d" , row .NumVal ),
87
- row .Encoding ,
88
- humanize .Bytes (uint64 (row .TotalCompressedSize )),
89
- humanize .Bytes (uint64 (row .TotalUncompressedSize )),
90
- fmt .Sprintf ("%.2f" , float64 (row .TotalUncompressedSize - row .TotalCompressedSize )/ float64 (row .TotalCompressedSize )* 100 ),
91
- fmt .Sprintf ("%.2f" , float64 (row .TotalUncompressedSize )/ float64 (row .TotalByteSize )* 100 ),
92
- })
87
+ table .Append ([]string {
88
+ k ,
89
+ row .Type ,
90
+ fmt .Sprintf ("%d" , row .NumVal ),
91
+ row .Encoding ,
92
+ humanize .Bytes (uint64 (row .TotalCompressedSize )),
93
+ humanize .Bytes (uint64 (row .TotalUncompressedSize )),
94
+ fmt .Sprintf ("%.2f" , float64 (row .TotalUncompressedSize - row .TotalCompressedSize )/ float64 (row .TotalCompressedSize )* 100 ),
95
+ fmt .Sprintf ("%.2f" , float64 (row .TotalUncompressedSize )/ float64 (row .TotalByteSize )* 100 ),
96
+ })
97
+
98
+ totalCompressedSize += row .TotalCompressedSize
99
+ totalUncompressedSize += row .TotalUncompressedSize
100
+ totalByteSize += row .TotalByteSize
93
101
}
102
+
103
+ table .Append ([]string {
104
+ "Total" ,
105
+ "" ,
106
+ "" ,
107
+ "" ,
108
+ humanize .Bytes (uint64 (totalCompressedSize )),
109
+ humanize .Bytes (uint64 (totalUncompressedSize )),
110
+ "" ,
111
+ "" ,
112
+ })
94
113
table .Render ()
95
114
96
115
return nil
97
116
}
117
+
118
+ func sum (a []int64 ) int64 {
119
+ var s int64
120
+ for _ , v := range a {
121
+ s += v
122
+ }
123
+ return s
124
+ }
0 commit comments