aboutsummaryrefslogtreecommitdiff
path: root/internal/bench/decompress.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2025-11-19 08:00:00 +0800
committerGravatar Runxi Yu2025-11-19 08:00:00 +0800
commit64b2b1acdec2b332cf62080aeafa89abf9e25826 (patch)
treee8b3b73a0860c27c7aa5d25f1b8e6954bec978c7 /internal/bench/decompress.go
parentImport flate (diff)
signatureNo signature
Add zlib test data
Diffstat (limited to 'internal/bench/decompress.go')
-rw-r--r--internal/bench/decompress.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/internal/bench/decompress.go b/internal/bench/decompress.go
new file mode 100644
index 00000000..c4a4d274
--- /dev/null
+++ b/internal/bench/decompress.go
@@ -0,0 +1,48 @@
+package main
+
+import (
+ "fmt"
+ "io"
+ "os"
+
+ "git.sr.ht/~runxiyu/furgit/internal/zlib"
+)
+
+func main() {
+ if len(os.Args) != 3 {
+ fmt.Fprintf(os.Stderr, "Usage: %s <input.zlib> <output>\n", os.Args[0])
+ os.Exit(1)
+ }
+
+ inputFile := os.Args[1]
+ outputFile := os.Args[2]
+
+ in, err := os.Open(inputFile)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Error opening input file: %v\n", err)
+ os.Exit(1)
+ }
+ defer in.Close()
+
+ out, err := os.Create(outputFile)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Error creating output file: %v\n", err)
+ os.Exit(1)
+ }
+ defer out.Close()
+
+ reader, err := zlib.NewReader(in)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Error creating zlib reader: %v\n", err)
+ os.Exit(1)
+ }
+ defer reader.Close()
+
+ _, err = io.Copy(out, reader)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Error decompressing data: %v\n", err)
+ os.Exit(1)
+ }
+
+ fmt.Fprintf(os.Stderr, "Successfully decompressed %s to %s\n", inputFile, outputFile)
+}