You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using oatpp web service framework and it's amazing and accelerating my backend dev works. However when I am running the oatpp api client demo and found out that the API calling is too slow.
I added the profiler for each API calling to test the time elapses.
As we can see the demo code implementation Code Snippet 1 and its running result in Code Snippet 2.
The http query responding time varied. Ranging from 300ms to 2100ms. Is the normal performance of the client side of oatpp? Is there something wrong within the demo code?
Any suggestions would be appreciated.
Code snippet 1
#ifndef SimpleExample_hpp
#define SimpleExample_hpp
#include "./DemoApiClient.hpp"
#include <chrono>
#include <iostream>
class Profiler {
public:
Profiler(){
timepoint_ = std::chrono::steady_clock::now(); // extract start time point
}
~Profiler(){
auto newtimepoint = std::chrono::steady_clock::now(); // extract end time point
auto diff = newtimepoint - timepoint_; // get diff
const auto count = std::chrono::duration <double, std::nano> (diff).count(); // convert to nanoseconds
auto ms = count / 1E6; // convert to milliseconds
std::cout << "time interval:" << ms << "(ms)" << std::endl; // print out
}
private:
std::chrono::steady_clock::time_point timepoint_;
};
class SimpleExample {
private:
constexpr static const char* TAG = "SimpleExample";
public:
void static runExample(const std::shared_ptr<DemoApiClient>& client) {
{
Profiler p;
auto data = client->doGet()->readBodyToString();
OATPP_LOGD(TAG, "[doGet] data='%s'", data->c_str());
}
{
Profiler p;
auto data = client->doPost("Some data passed to POST")->readBodyToString();
OATPP_LOGD(TAG, "[doPost] data='%s'", data->c_str());
}
{
Profiler p;
auto data = client->doGetAnything("path-parameter")->readBodyToString();
OATPP_LOGD(TAG, "[doGetAnything] data='%s'", data->c_str());
}
{
Profiler p;
auto data = client->doPostAnything("path-parameter", "Some body here")->readBodyToString();
OATPP_LOGD(TAG, "[doPostAnything] data='%s'", data->c_str());
}
{
Profiler p;
auto dto = MyRequestDto::createShared();
dto->message = "Some message";
dto->code = 200;
auto data = client->doPostWithDto(dto)->readBodyToString();
OATPP_LOGD(TAG, "[doPostWithDto] data='%s'", data->c_str());
}
}
};
#endif /* SimpleExample_hpp */
I believe that this might be a location/network thing since you are accessing a remote service.
An example is running against the httpbin.org which from my location is resolved to 3.211.1.78 - Virginia, USA.
Here are my results running the same example with your Profiler (location - Europe):
On WIFI:
time interval:290.852(ms)
time interval:245.506(ms)
time interval:245.742(ms)
time interval:242.067(ms)
time interval:243.209(ms)
On the Mobile network:
time interval:333.269(ms)
time interval:359.466(ms)
time interval:362.205(ms)
time interval:368.195(ms)
time interval:342.913(ms)
I'm using oatpp web service framework and it's amazing and accelerating my backend dev works. However when I am running the oatpp api client demo and found out that the API calling is too slow.
I added the profiler for each API calling to test the time elapses.
As we can see the demo code implementation Code Snippet 1 and its running result in Code Snippet 2.
The http query responding time varied. Ranging from 300ms to 2100ms. Is the normal performance of the client side of oatpp? Is there something wrong within the demo code?
Any suggestions would be appreciated.
Code snippet 1
Code snippet 2
The text was updated successfully, but these errors were encountered: