-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Description
#include <jinja2cpp/template.h>
#include <rapidjson/document.h>
#include <rapidjson/writer.h>
#include
using namespace jinja2;
int main() {
std::string source = "{{ title }}";
jinja2::Template tpl;
const int N = 100000;
auto start_time = std::chrono::high_resolution_clock::now();
for (int i = 0; i < N; i++)
{
tpl.Load(source);
}
ValuesMap data;
data["title"] = "My title";
data["t"] = "My List";
std::string result = tpl.RenderAsString(data).value();;
auto end_time = std::chrono::high_resolution_clock::now();
auto time_span = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time);
std::cout << "Loop time:" << time_span.count() << "milliseconds" << std::endl;
std::cout << result << std::endl;
return 0;
}
Release, the loop is 100,000 times, and it takes 20 seconds. Is there a problem with my usage?
Loop time: 19516 milliseconds
My title
Metadata
Metadata
Assignees
Labels
No labels