1#include <iostream>
2#include <iomanip>
3#include <limits>
4
5#include <Compression/CompressionFactory.h>
6#include <Compression/CachedCompressedReadBuffer.h>
7#include <IO/WriteBufferFromFile.h>
8#include <IO/copyData.h>
9
10#include <Common/Stopwatch.h>
11
12
13int main(int argc, char ** argv)
14{
15 using namespace DB;
16
17 if (argc < 2)
18 {
19 std::cerr << "Usage: program path\n";
20 return 1;
21 }
22
23 try
24 {
25 UncompressedCache cache(1024);
26 std::string path = argv[1];
27
28 std::cerr << std::fixed << std::setprecision(3);
29
30 size_t hits = 0;
31 size_t misses = 0;
32
33 {
34 Stopwatch watch;
35 CachedCompressedReadBuffer in(path, &cache, 0, 0);
36 WriteBufferFromFile out("/dev/null");
37 copyData(in, out);
38
39 std::cerr << "Elapsed: " << watch.elapsedSeconds() << std::endl;
40 }
41
42 cache.getStats(hits, misses);
43 std::cerr << "Hits: " << hits << ", misses: " << misses << std::endl;
44
45 {
46 Stopwatch watch;
47 CachedCompressedReadBuffer in(path, &cache, 0, 0);
48 WriteBufferFromFile out("/dev/null");
49 copyData(in, out);
50
51 std::cerr << "Elapsed: " << watch.elapsedSeconds() << std::endl;
52 }
53
54 cache.getStats(hits, misses);
55 std::cerr << "Hits: " << hits << ", misses: " << misses << std::endl;
56 }
57 catch (const Exception & e)
58 {
59 std::cerr << e.what() << ", " << e.displayText() << std::endl;
60 return 1;
61 }
62
63 return 0;
64}
65