Exemplo n.º 1
0
def test_huffman():
    camzip.camzip("huffman", "hamlet.txt")
    return
Exemplo n.º 2
0
def test_shanon_fano():
    camzip.camzip("shannon_fano", "hamlet.txt")
    return
Exemplo n.º 3
0
import os

import time

filename = "hamlet_10.txt"

#filename = "hamlet_extended.txt"

print("Original file size:", os.path.getsize(filename))

start_time = time.time()

method = "arithmetic"

camzip(method, filename)
print("Encoded")

print("Arith: --- %s seconds ---" % (time.time() - start_time))

print("File size:", os.path.getsize(filename + '.cz' + method[0]))

start2_time = time.time()

method = "context"

camzip(method, filename)

print("Context: --- %s seconds ---" % (time.time() - start2_time))

print("File size:", os.path.getsize(filename + '.cz' + method[0]))
Exemplo n.º 4
0
def test_arithmetic():
    camzip.camzip("arithmetic", "hamlet.txt")
    return
Exemplo n.º 5
0
from camzip import camzip
import matplotlib.pyplot as plt

cz = camzip()

hm = []
sf = []
x = []
for i in range(1, 10):
    hm.append(cz.zip('huffman', 'hamlet.txt', i, True))
    sf.append(cz.zip('shannon_fano', 'hamlet.txt', i, True))
    x.append(i)
plt.plot(x, hm, label='Huffman')
plt.plot(x, sf, label='Shannon-Fano')
plt.xlabel('N')
plt.ylabel('Compression Ratio')
plt.legend()
plt.grid()
plt.show()