-
Notifications
You must be signed in to change notification settings - Fork 1
/
WKdmIntoLZOTester.cc
80 lines (59 loc) · 2.22 KB
/
WKdmIntoLZOTester.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// WKdmIntoLZOTester.cc
// Scott F. Kaplan -- [email protected]
// May 1998
// A tester designed to work on the Wilson-Kaplan-dm algorithm that
// re-compressed its misses with LZO, a fast Lempel-Ziv implementation
// Note that it note only performs the requested compression and
// decompression, but also performs and keeps extra statisics for its
// own experiements that measure characteristics specific to this
// algorithm.
using namespace std;
#include <iostream>
#include <string.h>
#include "WKdmIntoLZOTester.hh"
#include "WKdm-into-LZO.h"
const unsigned int bytesPerWord = sizeof(int) / sizeof(char);
// Perform the actual task of timing the compression algorithm.
void
WKdmIntoLZOTester::performCompressionTest
(void* uncompressedData,
unsigned int uncompressedBytes,
unsigned int& returnCompressedSize,
unsigned long long& returnCompressionTime) {
WKdm_into_LZO_word compressionBuffer[4 * uncompressedBytes / bytesPerWord];
// Surround a call to the compression routine with a timing
// mechanism.
START_TIMER;
returnCompressedSize =
WKdm_into_LZO_compress((WKdm_into_LZO_word*)uncompressedData,
compressionBuffer,
uncompressedBytes);
STOP_TIMER(returnCompressionTime);
}
// Perform the actual task of timing the decompression algorithm.
void
WKdmIntoLZOTester::performDecompressionTest
(void* uncompressedData,
unsigned int uncompressedBytes,
unsigned int& returnPreDecompressionSize,
unsigned long long& returnDecompressionTime) {
returnPreDecompressionSize = 0;
returnDecompressionTime = 0;
unsigned int uncompressedWords =
uncompressedBytes / sizeof(WKdm_into_LZO_word);
WKdm_into_LZO_word compressionBuffer[4 * uncompressedWords];
WKdm_into_LZO_word decompressionBuffer[uncompressedWords];
// Get a compressed copy of the page so that the decompression can
// be timed.
returnPreDecompressionSize =
WKdm_into_LZO_compress((WKdm_into_LZO_word*)uncompressedData,
compressionBuffer,
uncompressedBytes);
// Surround a call to the decompression routine with a timing
// mechanism.
START_TIMER;
WKdm_into_LZO_decompress(compressionBuffer,
decompressionBuffer,
returnPreDecompressionSize);
STOP_TIMER(returnDecompressionTime);
}