Download harness.cpp from trevdatastreams/huntr-poc-avro-cpp-collection-count-allocation: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/trevdatastreams/huntr-poc-avro-cpp-collection-count-allocation/resolve/main/harness.cpp
- Command line
-
hf download hf://trevdatastreams/huntr-poc-avro-cpp-collection-count-allocation/harness.cpp
-
curl -L -o harness.cpp https://huggingface.co/trevdatastreams/huntr-poc-avro-cpp-collection-count-allocation/resolve/main/harness.cpp
1.48 kB
| namespace { | |
| std::uint64_t maximumResidentBytes() { | |
| rusage usage{}; | |
| getrusage(RUSAGE_SELF, &usage); | |
| return static_cast<std::uint64_t>(usage.ru_maxrss); | |
| return static_cast<std::uint64_t>(usage.ru_maxrss) * 1024; | |
| } | |
| } // namespace | |
| int main(int argc, char** argv) { | |
| if (argc != 2) { | |
| std::cerr << "usage: " << argv[0] << " FILE.avro\n"; | |
| return 2; | |
| } | |
| try { | |
| avro::DataFileReader<avro::GenericDatum> reader(argv[1]); | |
| avro::GenericDatum datum(reader.readerSchema()); | |
| const bool decoded = reader.read(datum); | |
| std::cout << "decoded=" << decoded | |
| << " max_rss_bytes=" << maximumResidentBytes() << "\n"; | |
| return 0; | |
| } catch (const std::bad_alloc& error) { | |
| std::cerr << "BAD_ALLOC " << error.what() | |
| << " max_rss_bytes=" << maximumResidentBytes() << "\n"; | |
| return 42; | |
| } catch (const std::length_error& error) { | |
| std::cerr << "LENGTH_ERROR " << error.what() | |
| << " max_rss_bytes=" << maximumResidentBytes() << "\n"; | |
| return 43; | |
| } catch (const std::exception& error) { | |
| std::cerr << "EXCEPTION " << error.what() | |
| << " max_rss_bytes=" << maximumResidentBytes() << "\n"; | |
| return 44; | |
| } | |
| } | |