-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support cloudfire optimized version of zlib as a backend
- Loading branch information
Showing
4 changed files
with
96 additions
and
8 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
extern crate flate2; | ||
|
||
use flate2::write::GzEncoder; | ||
use flate2::Compression; | ||
use std::io::prelude::*; | ||
use std::io::copy; | ||
use std::io::BufReader; | ||
use std::fs::File; | ||
use std::env::args; | ||
use std::time::Instant; | ||
|
||
// Vec<u8> implements Write to print the compressed bytes of sample string | ||
fn main() { | ||
let mut input = BufReader::new(File::open(args().nth(1).unwrap()).unwrap()); | ||
let output = File::create(args().nth(2).unwrap()).unwrap(); | ||
let mut encoder = GzEncoder::new(output, Compression::default()); | ||
let start = Instant::now(); | ||
copy(&mut input, &mut encoder).unwrap(); | ||
encoder.finish().unwrap(); | ||
let end = Instant::now(); | ||
println!("{:?}", end - start); | ||
} |
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
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