From d8c4d84dc75300c6d4d8b0adceafa33741960b92 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 27 Sep 2025 18:38:35 +0200 Subject: added http lib, working on AI invoice importing --- libs/cpp-httplib/example/benchmark.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 libs/cpp-httplib/example/benchmark.cc (limited to 'libs/cpp-httplib/example/benchmark.cc') diff --git a/libs/cpp-httplib/example/benchmark.cc b/libs/cpp-httplib/example/benchmark.cc new file mode 100644 index 0000000..433cc67 --- /dev/null +++ b/libs/cpp-httplib/example/benchmark.cc @@ -0,0 +1,33 @@ +#include +#include +#include + +using namespace std; + +struct StopWatch { + StopWatch(const string &label) : label_(label) { + start_ = chrono::system_clock::now(); + } + ~StopWatch() { + auto end = chrono::system_clock::now(); + auto diff = end - start_; + auto count = chrono::duration_cast(diff).count(); + cout << label_ << ": " << count << " millisec." << endl; + } + string label_; + chrono::system_clock::time_point start_; +}; + +int main(void) { + string body(1024 * 5, 'a'); + + httplib::Client cli("httpbin.org", 80); + + for (int i = 0; i < 3; i++) { + StopWatch sw(to_string(i).c_str()); + auto res = cli.Post("/post", body, "application/octet-stream"); + assert(res->status == httplib::StatusCode::OK_200); + } + + return 0; +} -- cgit v1.2.3-70-g09d2