Created
September 9, 2024 15:12
-
-
Save andiradulescu/251c72c46b9ebe196631cfdd1ce86cf1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lzma | |
import time | |
def benchmark_lzma_decompressor(compressed_data): | |
# Start the timer | |
start_time = time.time() | |
# Create an LZMADecompressor object | |
decompressor = lzma.LZMADecompressor() | |
# Perform decompression | |
try: | |
decompressed_data = decompressor.decompress(compressed_data) | |
except lzma.LZMAError as e: | |
print(f"Decompression error: {e}") | |
return None | |
# Stop the timer | |
end_time = time.time() | |
# Calculate the time taken | |
time_taken = end_time - start_time | |
print(f"Time taken to decompress: {time_taken:.6f} seconds") | |
return decompressed_data | |
# Sample compressed data (replace this with your actual compressed data) | |
compressed_data = lzma.compress(b"Test data to compress and benchmark" * 1000) | |
# Call the benchmark function | |
benchmark_lzma_decompressor(compressed_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment