Skip to content

Commit

Permalink
More profiling info
Browse files Browse the repository at this point in the history
  • Loading branch information
Senryoku committed Apr 23, 2024
1 parent f6bed7b commit 7b5347c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/profile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@ pub fn main() !void {
std.debug.print("Compression Time: {d:.3}ms\n", .{elapsed / std.time.ns_per_ms});
}

var compressed = try lzw.compress(str, allocator);
defer compressed.deinit();
{
const compressed = try lzw.compress(str, allocator);

const start = try std.time.Instant.now();
for (0..100) |_| {
const unpackedData = try compressed.unpackWithReset(allocator, std.math.maxInt(lzw.BitPacker.ValueType));
defer allocator.free(unpackedData);
}
const end = try std.time.Instant.now();
const elapsed: f64 = @floatFromInt(end.since(start));
std.debug.print("Unpacking Time: {d:.3}ms\n", .{elapsed / std.time.ns_per_ms});
}

{
const unpackedData = try compressed.unpackWithReset(allocator, std.math.maxInt(lzw.BitPacker.ValueType));
defer allocator.free(unpackedData);

const start = try std.time.Instant.now();
for (0..100) |_| {
var decompressed = try lzw.decompress(lzw.BitPacker.ValueType, 0, std.math.maxInt(lzw.BitPacker.ValueType), unpackedData, str.len, allocator);
defer decompressed.deinit();
}
Expand Down

0 comments on commit 7b5347c

Please sign in to comment.