-
Notifications
You must be signed in to change notification settings - Fork 1
/
WKdmWithLZOTester.cc
76 lines (58 loc) · 2.12 KB
/
WKdmWithLZOTester.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
// WKdmWithLZOTester.cc
// Scott F. Kaplan -- sfkaplan@cs.utexas.edu
// 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 <cstring>
#include "WKdmWithLZOTester.hh"
#include "WKdm-with-LZO.h"
const unsigned int bytesPerWord = sizeof(int) / sizeof(char);
// Perform the actual task of timing the compression algorithm.
void
WKdmWithLZOTester::performCompressionTest
(void* uncompressedData,
unsigned int uncompressedBytes,
unsigned int& returnCompressedSize,
unsigned long long& returnCompressionTime) {
WK_word compressionBuffer[4 * uncompressedBytes / bytesPerWord];
// Surround a call to the compression routine with a timing
// mechanism.
START_TIMER;
returnCompressedSize =
WKdm_with_LZO_compress((WK_word*)uncompressedData,
compressionBuffer,
uncompressedBytes);
STOP_TIMER(returnCompressionTime);
}
// Perform the actual task of timing the decompression algorithm.
void
WKdmWithLZOTester::performDecompressionTest
(void* uncompressedData,
unsigned int uncompressedBytes,
unsigned int& returnPreDecompressionSize,
unsigned long long& returnDecompressionTime) {
returnPreDecompressionSize = 0;
returnDecompressionTime = 0;
unsigned int uncompressedWords =
uncompressedBytes / sizeof(WK_word);
WK_word compressionBuffer[4 * uncompressedWords];
WK_word decompressionBuffer[uncompressedWords];
// Get a compressed copy of the page so that the decompression can
// be timed.
returnPreDecompressionSize =
WKdm_with_LZO_compress((WK_word*)uncompressedData,
compressionBuffer,
uncompressedBytes);
// Surround a call to the decompression routine with a timing
// mechanism.
START_TIMER;
WKdm_with_LZO_decompress(compressionBuffer,
decompressionBuffer);
STOP_TIMER(returnDecompressionTime);
}