engine

package
v0.0.0-...-5787e7a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Engines = [...]string{"all", "suite", "lzss", "dmc", "huffman", "mcc", "flate", "gzip", "lzw", "zlib", "arithmetic"}

Engines is a slice of strings representing possible algorithms.

View Source
var Readers = map[string]interface{}{
	"lzss":       lz.NewReader,
	"dmc":        dmc.NewReader,
	"mcc":        mcc.NewReader,
	"huffman":    huffman.NewReader,
	"arithmetic": arithmetic.NewReader,
	"zlib":       zlib.NewReader,
	"flate":      flate.NewReader,
	"gzip":       gzip.NewReader,
	"lzw":        lzw.NewReader,
}

Readers represents a map of algorithm names to their NewReader interfaces.

View Source
var Suites = map[string][]string{"all": Engines[2:], "suite": {"lzss", "dmc", "huffman", "mcc", "flate", "gzip", "lzw", "zlib", "arithmetic"}}

Suites is a map of strings to strings representing a suite name and the contained algorithms.

View Source
var Writers = map[string]interface{}{
	"lzss":       lz.NewWriter,
	"dmc":        dmc.NewWriter,
	"mcc":        mcc.NewWriter,
	"huffman":    huffman.NewWriter,
	"arithmetic": arithmetic.NewWriter,
	"zlib":       zlib.NewWriter,
	"flate":      flate.NewWriter,
	"gzip":       gzip.NewWriter,
	"lzw":        lzw.NewWriter,
}

Writers represents a map of algorithm names to their NewWriter interfaces.

Functions

func AsyncBenchmarkFile

func AsyncBenchmarkFile(resultChannel chan Result, wg *sync.WaitGroup, compressionEngines []string, fileString string)

AsyncBenchmarkFile takes a channel to push the result, a waitgroup, engines, a file string and runs the benchmark. The function will push the result to the channel or push a failed result if it is able to catch an error during execution.

func ByteCountSI

func ByteCountSI(b int64) string

ByteCountSI takes the number of bytes as an int64 and returns a human readable string in the largest significant units possible.

func CompressFile

func CompressFile(algorithms []string, path string, output string) []byte

CompressFile takes a set of compression algorithms as a string and a path to a file and writes out the file in the same path with .compressed appended to the end.

func CompressFiles

func CompressFiles(algorithms []string, files []string, extension string)

CompressFiles takes a set of compression algorithms as a string and multiple file paths as a slice and writes out the files in the same path with the extension appended.

func DecompressFile

func DecompressFile(algorithms []string, path string, output string) []byte

DecompressFile takes a set of compression algorithms as a string and a path to a file and writes out the decompressed file in the same path with .decompressed appended to the end.

func DecompressFiles

func DecompressFiles(algorithms []string, files []string, extension string)

DecompressFiles takes a set of compression algorithms as a string and and multiple file paths as a slice and writes out the decompressed files in the same path with .decompressed appended to the end.

Types

type CompressedFile

type CompressedFile struct {
	CompressionEngine string
	Compressed        []byte
	Decompressed      []byte

	MaxSearchBufferLength int
	// contains filtered or unexported fields
}

CompressedFile is a struct used to read a compressed file or write to a compressed file.

func GetCompressedFileFromPath

func GetCompressedFileFromPath(path string) (CompressedFile, error)

GetCompressedFileFromPath takes a path variable and returns a CompressedFile object or an error.

func (*CompressedFile) Read

func (f *CompressedFile) Read(content []byte) (int, error)

func (*CompressedFile) Write

func (f *CompressedFile) Write(content []byte) (int, error)

type Result

type Result struct {
	CompressionEngine string
	TimeTaken         string
	Ratio             float32
	ActualEntropy     float32
	Entropy           float64
	Lossless          bool
	Failed            bool
}

Result is an intermediary object used to represent the benchmarked results of a certain file and algorithm.

func BenchmarkFile

func BenchmarkFile(algorithms []string, fileString string, settings Settings) Result

BenchmarkFile takes a set of algorithms, a file path, and a settings object. It benchmarks the file and returns the result as a Result object.

func BenchmarkSuite

func BenchmarkSuite(files []string, algorithms [][]string, generateHTML bool) (string, []Result)

BenchmarkSuite takes a set of files and algorithms and returns the result as an html table if generateHTML is set. The result is also outputted to stdout.

type Settings

type Settings struct {
	WriteOutFiles bool
	PrintStats    bool
	PrintStatus   bool
}

Settings represents an object that can be used to modify the settings when benchmarking files with BenchmarkFile

func NewSuiteSettings

func NewSuiteSettings() Settings

NewSuiteSettings returns common settings for a testing suite as a Settings object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL