- 检查命令行参数的数量,如果不是3个,则打印错误信息并返回。
- 使用
BufReader
打开第一个命令行参数指定的文件,并将其赋值给input
变量。如果文件打开失败,会产生一个错误。 - 创建一个新的文件,用于存储压缩后的数据,并将其赋值给
output
变量。如果文件创建失败,会产生一个错误。 - 创建一个
GzEncoder
对象,将output
作为输出流,并使用默认的压缩级别。将该对象赋值给encoder
变量。 - 使用
Instant
记录当前时间,并将其赋值给start
变量。 - 将
input
的数据复制到encoder
中,实现文件的压缩。如果复制过程中发生错误,会产生一个错误。 - 调用
encoder
的finish
方法,完成压缩过程,并将结果赋值给output
变量。 - 打印原始文件的长度,使用
input.get_ref().metadata().unwrap().len()
获取原始文件的元数据,并打印其长度。 - 打印压缩后文件的长度,使用
output.metadata().unwrap().len()
获取压缩后文件的元数据,并打印其长度。 - 打印程序执行的时间,使用
start.elapsed()
获取程序执行的时间,并打印出来。
compress_youtube's Introduction
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.