Record the WOFF 2.0 compression improvement (%) in the CSV file
This commit is contained in:
@@ -72,6 +72,12 @@ public class CompressionStats {
|
||||
return sizes.get(size);
|
||||
}
|
||||
|
||||
public double getPercent(Size s1, Size s2) {
|
||||
long v1 = sizes.get(s1);
|
||||
long v2 = sizes.get(s2);
|
||||
return 100.0 * (v1 - v2) / v1;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
@@ -17,13 +17,14 @@ public class CsvReport {
|
||||
public static void create(CompressionStats stats, String filename) throws IOException {
|
||||
PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
|
||||
try {
|
||||
writer.printf("Font, Original, GZIP, WOFF 2.0\n");
|
||||
writer.printf("'Font', 'Original (bytes)', 'GZIP (bytes)', 'WOFF 2.0 (bytes)', '%% Improvement'\n");
|
||||
for (CompressionStats.Stats stat : stats.values()) {
|
||||
writer.printf("%s, %d, %d, %d\n",
|
||||
writer.printf("%s, %d, %d, %d, %.2f%%\n",
|
||||
stat.getFilename(),
|
||||
stat.getSize(CompressionStats.Size.ORIGINAL),
|
||||
stat.getSize(CompressionStats.Size.GZIP),
|
||||
stat.getSize(CompressionStats.Size.WOFF2));
|
||||
stat.getSize(CompressionStats.Size.WOFF2),
|
||||
stat.getPercent(CompressionStats.Size.GZIP, CompressionStats.Size.WOFF2));
|
||||
}
|
||||
} finally {
|
||||
Closeables.closeQuietly(writer);
|
||||
|
||||
Reference in New Issue
Block a user