2013-09-08 05:53:10 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
2015-03-31 12:23:22 +00:00
|
|
|
#include <limits>
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2018-12-13 10:25:11 +00:00
|
|
|
#include <Compression/CompressionFactory.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <IO/CachedCompressedReadBuffer.h>
|
|
|
|
#include <IO/WriteBufferFromFile.h>
|
|
|
|
#include <IO/copyData.h>
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Common/Stopwatch.h>
|
2013-09-08 05:53:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char ** argv)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
using namespace DB;
|
2017-03-31 16:00:30 +00:00
|
|
|
|
2017-12-01 18:36:55 +00:00
|
|
|
if (argc < 2)
|
|
|
|
{
|
|
|
|
std::cerr << "Usage: program path\n";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
UncompressedCache cache(1024);
|
|
|
|
std::string path = argv[1];
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
std::cerr << std::fixed << std::setprecision(3);
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t hits = 0;
|
|
|
|
size_t misses = 0;
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Stopwatch watch;
|
2018-12-20 17:37:02 +00:00
|
|
|
CachedCompressedReadBuffer in(path, &cache, 0, 0);
|
2017-04-01 07:20:54 +00:00
|
|
|
WriteBufferFromFile out("/dev/null");
|
|
|
|
copyData(in, out);
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
std::cerr << "Elapsed: " << watch.elapsedSeconds() << std::endl;
|
|
|
|
}
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
cache.getStats(hits, misses);
|
|
|
|
std::cerr << "Hits: " << hits << ", misses: " << misses << std::endl;
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
|
|
|
Stopwatch watch;
|
2018-12-20 17:37:02 +00:00
|
|
|
CachedCompressedReadBuffer in(path, &cache, 0, 0);
|
2017-04-01 07:20:54 +00:00
|
|
|
WriteBufferFromFile out("/dev/null");
|
|
|
|
copyData(in, out);
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
std::cerr << "Elapsed: " << watch.elapsedSeconds() << std::endl;
|
|
|
|
}
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
cache.getStats(hits, misses);
|
|
|
|
std::cerr << "Hits: " << hits << ", misses: " << misses << std::endl;
|
|
|
|
}
|
|
|
|
catch (const Exception & e)
|
|
|
|
{
|
|
|
|
std::cerr << e.what() << ", " << e.displayText() << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
2013-09-08 05:53:10 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
return 0;
|
2013-09-08 05:53:10 +00:00
|
|
|
}
|