Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only read first 512 bytes #2

Merged
merged 1 commit into from
May 24, 2013

Conversation

kevinsawicki
Copy link
Contributor

Since only the first 512 bytes are considered, only read the first 512 bytes instead of the entire file.

This improves performance noticeably for files in the hundreds of megabytes:

> ls -al /tmp/huge.zip
-rw-r--r--  1 kevin  wheel  237545472 May 24 12:24 /tmp/huge.zip

> git co master 
> time bin/isbinaryfile /tmp/huge.zip
real    0m0.250s
user    0m0.067s
sys     0m0.183s

> git co read-first-512-only
> time bin/isbinaryfile /tmp/huge.zip
real    0m0.101s
user    0m0.065s
sys     0m0.035s

@gjtorikian
Copy link
Owner

ah, yeah, I've only ever used this in the context of the file already being read. 😺

mergin'.

gjtorikian added a commit that referenced this pull request May 24, 2013
@gjtorikian gjtorikian merged commit a5f6021 into gjtorikian:master May 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants