MCPcopy Create free account
hub / github.com/ada-url/ada / init_data

Function init_data

benchmarks/bench.cpp:43–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41#endif
42
43size_t init_data(const char* input = default_file) {
44 // compute the number of bytes.
45 auto compute = []() -> double {
46 size_t bytes{0};
47 for (std::string& url_string : url_examples) {
48 bytes += url_string.size();
49 }
50 return double(bytes);
51 };
52 if (input == nullptr) {
53 for (const std::string& s : url_examples_default) {
54 url_examples.emplace_back(s);
55 }
56 url_examples_bytes = compute();
57 return url_examples.size();
58 }
59
60 if (!file_exists(input)) {
61 std::cout << "File not found !" << input << std::endl;
62 for (const std::string& s : url_examples_default) {
63 url_examples.emplace_back(s);
64 }
65 } else {
66 std::cout << "Loading " << input << std::endl;
67 url_examples = split_string(read_file(input));
68 }
69 url_examples_bytes = compute();
70 return url_examples.size();
71}
72
73#ifndef BENCHMARK_PREFIX
74#define BENCHMARK_PREFIX Bench_

Callers 1

mainFunction · 0.70

Calls 4

sizeMethod · 0.80
file_existsFunction · 0.70
split_stringFunction · 0.70
read_fileFunction · 0.70

Tested by

no test coverage detected