Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
47bb5ae8
Commit
47bb5ae8
authored
Jun 16, 2015
by
Chris Bednarski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-added benchmark and license
parent
2d6f8279
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
218 additions
and
0 deletions
+218
-0
post-processor/compress/LICENSE
post-processor/compress/LICENSE
+21
-0
post-processor/compress/benchmark.go
post-processor/compress/benchmark.go
+197
-0
No files found.
post-processor/compress/LICENSE
0 → 100644
View file @
47bb5ae8
The MIT License (MIT)
Copyright (c) 2014 Vasiliy Tolstov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
post-processor/compress/benchmark.go
0 → 100644
View file @
47bb5ae8
// +build ignore
package
main
import
(
"compress/flate"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"os"
"runtime"
"testing"
"github.com/biogo/hts/bgzf"
"github.com/klauspost/pgzip"
"github.com/pierrec/lz4"
)
type
Compressor
struct
{
r
*
os
.
File
w
*
os
.
File
sr
int64
sw
int64
}
func
(
c
*
Compressor
)
Close
()
error
{
var
err
error
fi
,
_
:=
c
.
w
.
Stat
()
c
.
sw
=
fi
.
Size
()
if
err
=
c
.
w
.
Close
();
err
!=
nil
{
return
err
}
fi
,
_
=
c
.
r
.
Stat
()
c
.
sr
=
fi
.
Size
()
if
err
=
c
.
r
.
Close
();
err
!=
nil
{
return
err
}
return
nil
}
func
NewCompressor
(
src
,
dst
string
)
(
*
Compressor
,
error
)
{
r
,
err
:=
os
.
Open
(
src
)
if
err
!=
nil
{
return
nil
,
err
}
w
,
err
:=
os
.
Create
(
dst
)
if
err
!=
nil
{
r
.
Close
()
return
nil
,
err
}
c
:=
&
Compressor
{
r
:
r
,
w
:
w
}
return
c
,
nil
}
func
main
()
{
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
var
resw
testing
.
BenchmarkResult
var
resr
testing
.
BenchmarkResult
c
,
err
:=
NewCompressor
(
"/tmp/image.r"
,
"/tmp/image.w"
)
if
err
!=
nil
{
panic
(
err
)
}
resw
=
testing
.
Benchmark
(
c
.
BenchmarkGZIPWriter
)
c
.
w
.
Seek
(
0
,
0
)
resr
=
testing
.
Benchmark
(
c
.
BenchmarkGZIPReader
)
c
.
Close
()
fmt
.
Printf
(
"gzip:
\t
writer %s
\t
reader %s
\t
size %d
\n
"
,
resw
.
T
.
String
(),
resr
.
T
.
String
(),
c
.
sw
)
c
,
err
=
NewCompressor
(
"/tmp/image.r"
,
"/tmp/image.w"
)
if
err
!=
nil
{
panic
(
err
)
}
resw
=
testing
.
Benchmark
(
c
.
BenchmarkBGZFWriter
)
c
.
w
.
Seek
(
0
,
0
)
resr
=
testing
.
Benchmark
(
c
.
BenchmarkBGZFReader
)
c
.
Close
()
fmt
.
Printf
(
"bgzf:
\t
writer %s
\t
reader %s
\t
size %d
\n
"
,
resw
.
T
.
String
(),
resr
.
T
.
String
(),
c
.
sw
)
c
,
err
=
NewCompressor
(
"/tmp/image.r"
,
"/tmp/image.w"
)
if
err
!=
nil
{
panic
(
err
)
}
resw
=
testing
.
Benchmark
(
c
.
BenchmarkPGZIPWriter
)
c
.
w
.
Seek
(
0
,
0
)
resr
=
testing
.
Benchmark
(
c
.
BenchmarkPGZIPReader
)
c
.
Close
()
fmt
.
Printf
(
"pgzip:
\t
writer %s
\t
reader %s
\t
size %d
\n
"
,
resw
.
T
.
String
(),
resr
.
T
.
String
(),
c
.
sw
)
c
,
err
=
NewCompressor
(
"/tmp/image.r"
,
"/tmp/image.w"
)
if
err
!=
nil
{
panic
(
err
)
}
resw
=
testing
.
Benchmark
(
c
.
BenchmarkLZ4Writer
)
c
.
w
.
Seek
(
0
,
0
)
resr
=
testing
.
Benchmark
(
c
.
BenchmarkLZ4Reader
)
c
.
Close
()
fmt
.
Printf
(
"lz4:
\t
writer %s
\t
reader %s
\t
size %d
\n
"
,
resw
.
T
.
String
(),
resr
.
T
.
String
(),
c
.
sw
)
}
func
(
c
*
Compressor
)
BenchmarkGZIPWriter
(
b
*
testing
.
B
)
{
cw
,
_
:=
gzip
.
NewWriterLevel
(
c
.
w
,
flate
.
BestSpeed
)
b
.
ResetTimer
()
_
,
err
:=
io
.
Copy
(
cw
,
c
.
r
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
cw
.
Close
()
c
.
w
.
Sync
()
}
func
(
c
*
Compressor
)
BenchmarkGZIPReader
(
b
*
testing
.
B
)
{
cr
,
_
:=
gzip
.
NewReader
(
c
.
w
)
b
.
ResetTimer
()
_
,
err
:=
io
.
Copy
(
ioutil
.
Discard
,
cr
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
}
func
(
c
*
Compressor
)
BenchmarkBGZFWriter
(
b
*
testing
.
B
)
{
cw
,
_
:=
bgzf
.
NewWriterLevel
(
c
.
w
,
flate
.
BestSpeed
,
runtime
.
NumCPU
())
b
.
ResetTimer
()
_
,
err
:=
io
.
Copy
(
cw
,
c
.
r
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
c
.
w
.
Sync
()
}
func
(
c
*
Compressor
)
BenchmarkBGZFReader
(
b
*
testing
.
B
)
{
cr
,
_
:=
bgzf
.
NewReader
(
c
.
w
,
0
)
b
.
ResetTimer
()
_
,
err
:=
io
.
Copy
(
ioutil
.
Discard
,
cr
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
}
func
(
c
*
Compressor
)
BenchmarkPGZIPWriter
(
b
*
testing
.
B
)
{
cw
,
_
:=
pgzip
.
NewWriterLevel
(
c
.
w
,
flate
.
BestSpeed
)
b
.
ResetTimer
()
_
,
err
:=
io
.
Copy
(
cw
,
c
.
r
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
cw
.
Close
()
c
.
w
.
Sync
()
}
func
(
c
*
Compressor
)
BenchmarkPGZIPReader
(
b
*
testing
.
B
)
{
cr
,
_
:=
pgzip
.
NewReader
(
c
.
w
)
b
.
ResetTimer
()
_
,
err
:=
io
.
Copy
(
ioutil
.
Discard
,
cr
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
}
func
(
c
*
Compressor
)
BenchmarkLZ4Writer
(
b
*
testing
.
B
)
{
cw
:=
lz4
.
NewWriter
(
c
.
w
)
// cw.Header.HighCompression = true
cw
.
Header
.
NoChecksum
=
true
b
.
ResetTimer
()
_
,
err
:=
io
.
Copy
(
cw
,
c
.
r
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
cw
.
Close
()
c
.
w
.
Sync
()
}
func
(
c
*
Compressor
)
BenchmarkLZ4Reader
(
b
*
testing
.
B
)
{
cr
:=
lz4
.
NewReader
(
c
.
w
)
b
.
ResetTimer
()
_
,
err
:=
io
.
Copy
(
ioutil
.
Discard
,
cr
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment