MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / mainEntryExampleHashesTest

Function mainEntryExampleHashesTest

src/Common/examples/hashes_test.cpp:15–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13
14
15int mainEntryExampleHashesTest(int, char **)
16{
17 using Strings = std::vector<std::string>;
18 using Hashes = std::vector<char>;
19 Strings strings;
20 size_t rows = 0;
21 size_t bytes = 0;
22
23 {
24 Stopwatch watch;
25
26 DB::ReadBufferFromFileDescriptor in(STDIN_FILENO);
27
28 while (!in.eof())
29 {
30 strings.push_back(std::string());
31 DB::readEscapedString(strings.back(), in);
32 DB::assertChar('\n', in);
33 bytes += strings.back().size() + 1;
34 }
35
36 watch.stop();
37 rows = strings.size();
38 std::cerr << std::fixed << std::setprecision(2)
39 << "Read " << rows << " rows, " << static_cast<double>(bytes) / 1000000.0 << " MB"
40 << ", elapsed: " << watch.elapsedSeconds()
41 << " (" << static_cast<double>(rows) / watch.elapsedSeconds() << " rows/sec., " << static_cast<double>(bytes) / 1000000.0 / watch.elapsedSeconds() << " MB/sec.)"
42 << std::endl;
43 }
44
45 Hashes hashes(16 * rows);
46
47 {
48 Stopwatch watch;
49
50 for (size_t i = 0; i < rows; ++i)
51 {
52 *reinterpret_cast<UInt64*>(&hashes[i * 16]) = CityHash_v1_0_2::CityHash64(strings[i].data(), strings[i].size());
53 }
54
55 watch.stop();
56
57 UInt64 check = CityHash_v1_0_2::CityHash64(hashes.data(), hashes.size());
58
59 std::cerr << std::fixed << std::setprecision(2)
60 << "CityHash64 (check = " << check << ")"
61 << ", elapsed: " << watch.elapsedSeconds()
62 << " (" << static_cast<double>(rows) / watch.elapsedSeconds() << " rows/sec., " << static_cast<double>(bytes) / 1000000.0 / watch.elapsedSeconds() << " MB/sec.)"
63 << std::endl;
64 }
65
66/* {
67 Stopwatch watch;
68
69 std::vector<char> seed(16);
70
71 for (size_t i = 0; i < rows; ++i)
72 {

Callers

nothing calls this directly

Calls 13

readEscapedStringFunction · 0.85
assertCharFunction · 0.85
CityHash64Function · 0.85
getSipHash128AsArrayFunction · 0.85
memcpyFunction · 0.85
eofMethod · 0.45
push_backMethod · 0.45
backMethod · 0.45
sizeMethod · 0.45
stopMethod · 0.45
elapsedSecondsMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected