diff options
author | snow <snow@yandex-team.ru> | 2022-02-10 16:49:51 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:51 +0300 |
commit | b3f165d1a2e8a2dbfcbb351310aeb05fae1f8a6c (patch) | |
tree | 8f92b813636cef1b46a00d28d05c485d385f1ac0 /library/cpp/comptable/usage | |
parent | c943ab142d4182af287664691cf116c143172792 (diff) | |
download | ydb-b3f165d1a2e8a2dbfcbb351310aeb05fae1f8a6c.tar.gz |
Restoring authorship annotation for <snow@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/comptable/usage')
-rw-r--r-- | library/cpp/comptable/usage/usage.cpp | 94 | ||||
-rw-r--r-- | library/cpp/comptable/usage/ya.make | 10 |
2 files changed, 52 insertions, 52 deletions
diff --git a/library/cpp/comptable/usage/usage.cpp b/library/cpp/comptable/usage/usage.cpp index 9997c83686..60ed9b9422 100644 --- a/library/cpp/comptable/usage/usage.cpp +++ b/library/cpp/comptable/usage/usage.cpp @@ -1,75 +1,75 @@ #include <library/cpp/comptable/comptable.h> - + #include <util/random/random.h> #include <util/random/fast.h> #include <time.h> #include <stdlib.h> -using namespace NCompTable; - +using namespace NCompTable; + template <bool HQ> void DoTest(const TCompressorTable& table, const TVector<TString>& lines) { TVector<char> compressed; TVector<char> decompressed; - - TChunkCompressor compressor(HQ, table); - TChunkDecompressor deCompressor(HQ, table); - - size_t origSize = 0; - size_t compSize = 0; - float cl1 = clock(); + + TChunkCompressor compressor(HQ, table); + TChunkDecompressor deCompressor(HQ, table); + + size_t origSize = 0; + size_t compSize = 0; + float cl1 = clock(); for (size_t i = 0; i < lines.size(); ++i) { const TString& line = lines[i]; - compressor.Compress(line, &compressed); - origSize += line.size(); - compSize += compressed.size(); - TStringBuf in(compressed.data(), compressed.size()); - deCompressor.Decompress(in, &decompressed); + compressor.Compress(line, &compressed); + origSize += line.size(); + compSize += compressed.size(); + TStringBuf in(compressed.data(), compressed.size()); + deCompressor.Decompress(in, &decompressed); if (decompressed.size() != line.size() || memcmp(decompressed.data(), line.data(), decompressed.size())) { - Cout << i << "\n"; + Cout << i << "\n"; Cout << line << "\n" << TString(decompressed.data(), decompressed.size()) << "\n"; - abort(); - } - } - float cl2 = clock(); - float secs = (cl2 - cl1) / CLOCKS_PER_SEC; - Cout << "origSize: " << origSize << "\tcompSize: " << compSize << Endl; + abort(); + } + } + float cl2 = clock(); + float secs = (cl2 - cl1) / CLOCKS_PER_SEC; + Cout << "origSize: " << origSize << "\tcompSize: " << compSize << Endl; Cout << "yep! compression + decompression speed " << origSize / 1024.0f / 1024.0f / secs << " mbps\n"; - Cout << "yep! compression ratio " << double(origSize) / double(compSize + 1) << "\n"; -} - + Cout << "yep! compression ratio " << double(origSize) / double(compSize + 1) << "\n"; +} + int main(int argc, const char* argv[]) { TReallyFastRng32 rr(17); TVector<TString> lines; - /*FILE *fp = fopen("res", "rb"); - while (!feof(fp)) { - char buff[4096]; - fscanf(fp, "%s", buff); + /*FILE *fp = fopen("res", "rb"); + while (!feof(fp)) { + char buff[4096]; + fscanf(fp, "%s", buff); lines.push_back(TString(buff)); - }*/ - //for (size_t i = 0; i < 10000000; ++i) { - //for (size_t i = 0; i < 1000000; ++i) { + }*/ + //for (size_t i = 0; i < 10000000; ++i) { + //for (size_t i = 0; i < 1000000; ++i) { for (size_t i = 0; i < 1000000; ++i) { size_t size = rr.Uniform(32); TString res = "www.yandex.ru/yandsearch?text="; - for (size_t j = 0; j < size; ++j) { + for (size_t j = 0; j < size; ++j) { res += "qwer"[rr.Uniform(4)]; - } - lines.push_back(res); - } - THolder<TDataSampler> sampler(new TDataSampler); - for (size_t i = 0; i < lines.size(); ++i) { + } + lines.push_back(res); + } + THolder<TDataSampler> sampler(new TDataSampler); + for (size_t i = 0; i < lines.size(); ++i) { sampler->AddStat(lines[i]); - } - TCompressorTable table; - sampler->BuildTable(table); - - DoTest<true>(table, lines); - DoTest<false>(table, lines); - + } + TCompressorTable table; + sampler->BuildTable(table); + + DoTest<true>(table, lines); + DoTest<false>(table, lines); + Y_UNUSED(argc); Y_UNUSED(argv); - return 0; -} + return 0; +} diff --git a/library/cpp/comptable/usage/ya.make b/library/cpp/comptable/usage/ya.make index ab31e7528c..b23b545623 100644 --- a/library/cpp/comptable/usage/ya.make +++ b/library/cpp/comptable/usage/ya.make @@ -1,13 +1,13 @@ -PROGRAM() - +PROGRAM() + OWNER(ironpeter) - + SRCS( usage.cpp ) - + PEERDIR( library/cpp/comptable ) -END() +END() |