remove testing struct sizes

It was usefull during development.

From andrewrk code review comment:
In fact, Zig does not guarantee the @sizeOf structs, and so these tests are not valid.
This commit is contained in:
Igor Anić 2024-02-14 21:06:45 +01:00
parent d49cdf5b2d
commit 0afe808928
2 changed files with 0 additions and 63 deletions

View File

@ -602,50 +602,6 @@ const TestTokenWriter = struct {
pub fn flush(_: *Self) !void {}
};
test "flate.Deflate struct sizes" {
if (@sizeOf(usize) != 8) return error.SkipZigTest;
try expect(@sizeOf(Token) == 4);
// list: (1 << 15) * 4 = 128k + pos: 8
const tokens_size = 128 * 1024 + 8;
try expect(@sizeOf(Tokens) == tokens_size);
// head: (1 << 15) * 2 = 64k, chain: (32768 * 2) * 2 = 128k = 192k
const lookup_size = 192 * 1024;
try expect(@sizeOf(Lookup) == lookup_size);
// buffer: (32k * 2), wp: 8, rp: 8, fp: 8
const window_size = 64 * 1024 + 8 + 8 + 8;
try expect(@sizeOf(SlidingWindow) == window_size);
const Bw = BlockWriter(@TypeOf(io.null_writer));
// huffman bit writer internal: 11480
const hbw_size = 11472; // 11.2k
try expect(@sizeOf(Bw) == hbw_size);
const D = Deflate(.raw, @TypeOf(io.null_writer), Bw);
// 404744, 395.26K
// ?Token: 6, ?u8: 2, level: 8
try expect(@sizeOf(D) == tokens_size + lookup_size + window_size + hbw_size + 24);
//print("Delfate size: {d} {d}\n", .{ @sizeOf(D), tokens_size + lookup_size + hbw_size + window_size });
// current std lib deflate allocation:
// 797_901, 779.2k
// measured with:
// var la = std.heap.logToWriterAllocator(testing.allocator, io.getStdOut().writer());
// const allocator = la.allocator();
// var cmp = try std.compress.deflate.compressor(allocator, io.null_writer, .{});
// defer cmp.deinit();
const HC = huffman.Compressor(.raw, @TypeOf(io.null_writer));
//print("size of HOC {d}\n", .{@sizeOf(HOC)});
try expect(@sizeOf(HC) == 77024);
// 64K buffer
// 11480 huffman_encoded
// 8 buffer write pointer
}
test "flate deflate file tokenization" {
const levels = [_]Level{ .level_4, .level_5, .level_6, .level_7, .level_8, .level_9 };
const cases = [_]struct {

View File

@ -341,25 +341,6 @@ pub fn Inflate(comptime container: Container, comptime ReaderType: type) type {
};
}
test "flate.Inflate struct sizes" {
if (@sizeOf(usize) != 8) return error.SkipZigTest;
var fbs = std.io.fixedBufferStream("");
const ReaderType = @TypeOf(fbs.reader());
const inflate_size = @sizeOf(Inflate(.gzip, ReaderType));
try testing.expectEqual(76320, inflate_size);
try testing.expectEqual(
@sizeOf(CircularBuffer) + @sizeOf(hfd.LiteralDecoder) + @sizeOf(hfd.DistanceDecoder) + 48,
inflate_size,
);
try testing.expectEqual(65536 + 8 + 8, @sizeOf(CircularBuffer));
try testing.expectEqual(8, @sizeOf(Container.raw.Hasher()));
try testing.expectEqual(24, @sizeOf(BitReader(ReaderType)));
try testing.expectEqual(6384, @sizeOf(hfd.LiteralDecoder));
try testing.expectEqual(4336, @sizeOf(hfd.DistanceDecoder));
}
test "flate.Inflate decompress" {
const cases = [_]struct {
in: []const u8,