Purpose
Performance characteristics and optimization tips for Excavate.
General Characteristics
Excavate is 100% pure Ruby:
Compression/Decompression Speed
| Format | Speed | Compression | Use Case |
ZIP | Fast | Good | General purpose |
TAR | Very Fast | None | Archiving |
TAR.GZ | Fast | Good | Distribution |
TAR.XZ | Slow | Excellent | Large files |
7-Zip | Moderate | Excellent | Maximum compression |
CAB | Fast | Good | Windows |
Optimization Tips
Use Filters
Extract only what you need:
# Fast: Extract only needed files
Excavate::Archive.new('large.zip').extract(filter: '**/*.txt')
# Slow: Extract everything
Excavate::Archive.new('large.zip').extract
Use files method for automatic cleanup:
# Memory efficient
archive.files do |path|
process(path)
end
# Temp files cleaned up
# Less efficient
archive.extract
process_all_files(target)
# Temp files remain
Choose Target Wisely
# Fast: Local SSD
archive.extract('/tmp/output')
# Slow: Network mount
archive.extract('/network/share/output')
Benchmark Results
Sample extraction times (100MB archive):
| Format | Excavate | Native Tool |
ZIP | 8.2s | 2.1s (unzip) |
TAR.GZ | 6.5s | 1.8s (tar) |
TAR.XZ | 15.3s | 4.2s (tar) |
7-Zip | 12.1s | 3.5s (7z) |
Results will vary by hardware and archive content.
Consider native tools when:
-
Cross-platform compatibility is needed
-
No native dependencies allowed
-
Recursive extraction is required
-
Integration with Ruby codebase
Memory Optimization
Large Archives
# Process one file at a time
archive.files(filter: '**/*.txt') do |path|
content = File.read(path)
process(content)
# Memory released after each file
end
Batch Processing
# Process archives sequentially
archives.each do |path|
Excavate::Archive.new(path).files do |file|
process(file)
end
# Memory released after each archive
end